我需要从pdfs中提取表格数据。pdf中的一些表只包含一行。我一直在尝试使用camelot库提取数据。
使用Camelot提取代码:
pip install camelot-py[cv] tabula-py here
import camelot
file = 'xyz.pdf'
tables = camelot.read_pdf(file,pages ="all")
tables[6].df
以上代码无法提取单个行表信息。
例如,在pdf:https://www.nirfindia.org/nirfpdfcdn/2022/pdf/Engineering/IR-E-U-0306.pdf中,该工具无法检测到最后一个表格(在标题“教师详细信息”下),因为它只有一行。
有人能提出解决办法吗?
发布于 2022-11-24 09:47:13
从文档中可以了解到,如果要检测较小的行,应该增加line_scale
参数(默认值: 15)。
在您的示例中,此命令运行良好:
tables = camelot.read_pdf(file, pages ="all", line_scale=80)
https://stackoverflow.com/questions/74533410
复制相似问题