- git clone https://github.com/RapidAI/TableStructureRec.git
-
- pip install -r requirements.txt
-
- from bs4 import BeautifulSoup
- import os
-
- # 设置输入文件夹和输出文件路径
- input_folder = r'input_images'
- output_file = r'/merged.html'
-
- # 存储所有表格内容的列表
- all_tables = []
-
- # 遍历文件夹中的所有HTML文件
- for filename in os.listdir(input_folder):
- if filename.endswith('.html'):
- filepath = os.path.join(input_folder, filename)
-
- # 读取HTML文件内容
- with open(filepath, 'r', encoding='utf-8') as file:
- html_content = file.read()
-
- # 使用Beautiful Soup解析HTML
- soup = BeautifulSoup(html_content, 'html.parser')
-
- # 查找所有表格
- tables = soup.find_all('table')
-
- # 将每个表格的内容添加到列表中
- for table in tables:
- all_tables.append(str(table)) # 将Beautiful Soup对象转换为字符串存储
-
- # 创建输出HTML文件
- with open(output_file, 'w', encoding='utf-8') as outfile:
- # 写入HTML头部和开始标签
- outfile.write('<!DOCTYPE html>\n<html>\n<head>\n<title>Merged Tables</title>\n</head>\n<body>\n')
-
- # 逐一将所有表格内容写入输出文件
- for table_html in all_tables:
- outfile.write(table_html)
- outfile.write('\n') # 每个表格之间添加换行
-
- # 写入HTML结束标签
- outfile.write('</body>\n</html>\n')
-
- print(f'Merged HTML file saved to: {output_file}')
-
-
paddleocr 对于大部分表格内容识别准确率比较高 不能很好识别复杂表格格式 表格里的数据出现错误的概率比较低 遇到一些处理失败的时候 处理结果比较糟糕
wired_table_rec 能识别几乎所有的表格 能够将表格的格式 完整正确的表示出来 问题是 在表格内容识别上会出现一些数据没有识别出来的错误