表格解析调研

表格解析调研

TextInTools

TextInTools:https://tools.textin.com/table

可以将表格图片解析成可编辑的表格/json,效果不错

白描

地址:https://web.baimiaoapp.com/image-to-excel

可以将表格图片识别成可编辑的表格,可复制、导出为xlsx、txt。效果不错,但是免费有额度

i2PDF

地址:https://www.i2pdf.com/cn/extract-tables-from-pdf

可以对pdf进行多种处理,提取表格效果不错,并且可以选择导出的格式,效果不错

Tabula-PDF

项目地址:https://github.com/tabulapdf/tabula

用于从PDF文档中识别和提取表格数据。它利用机器学习算法和计算机视觉技术,能够准确地识别PDF页面中的表格,并将其转换为结构化数据。Tabula-PDF会将识别到的表格转换为结构化数据,如CSV、Excel、json等格式。效果一般

pdflux

项目地址:https://pdflux.com/

效果不错,会有免费额度

iLoveOCR

地址:https://cn.iloveocr.com/

效果一般

ocr2edit

地址:https://www.ocr2edit.com/zh

识别效果不好

py代码

使用python-docx库

python代码实现将word中的表格解析出来

python 复制代码
from docx import Document

doc = Document('example.docx')
for table in doc.tables:
    for row in table.rows:
        cells = [cell.text for cell in row.cells]
        print(cells)

使用PyMuPDF

需要安装PyMuPDF,可以用来提取pdf内容,并且可以查找页面的表格。效果不错

python 复制代码
import fitz

doc = fitz.open('../example.pdf')
page = doc[2]  # 下标从0开始
tables = page.find_tables()
df = tables[1].to_pandas()

df.to_excel('table.xlsx', index=False)

使用pdfplumber库

使用pdfplumber实现将pdf中的表格解析出来,效果一般,示例代码如下:

python 复制代码
import pdfplumber
import pandas as pd

with pdfplumber.open("../example.pdf") as pdf:
    page = pdf.pages[3]
    for table in page.extract_tables():
        df = pd.DataFrame(table[1:], columns=table[0])
        df.to_excel('table.xlsx', index=False)

使用camelot库

camelot专门用于从 PDF 文件中提取表格数据。效果不错

python 复制代码
import camelot

tables = camelot.read_pdf('../example.pdf')

tables.export('result.csv', f='csv', compress=True) # json, excel, html, markdown, sqlite

print(tables[0].parsing_report)

tables[0].to_csv('result.csv') # to_json, to_excel, to_html, to_markdown, to_sqlite
相关推荐
数据智能老司机几秒前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i1 小时前
django中的FBV 和 CBV
python·django
c8i1 小时前
python中的闭包和装饰器
python
这里有鱼汤5 小时前
小白必看:QMT里的miniQMT入门教程
后端·python
TF男孩15 小时前
ARQ:一款低成本的消息队列,实现每秒万级吞吐
后端·python·消息队列
该用户已不存在20 小时前
Mojo vs Python vs Rust: 2025年搞AI,该学哪个?
后端·python·rust
站大爷IP1 天前
Java调用Python的5种实用方案:从简单到进阶的全场景解析
python
用户8356290780511 天前
从手动编辑到代码生成:Python 助你高效创建 Word 文档
后端·python
_落纸1 天前
三大基础无源电子元件——电阻(R)、电感(L)、电容(C)
笔记
c8i1 天前
python中类的基本结构、特殊属性于MRO理解
python