Camelot-py未在一行中检测到两行文本

使用Camelot-py从.PDF抓取表格数据,并且没有拾取堆积的文本行(请参阅下面的第9和10行)

Camelot-py未在一行中检测到两行文本

Rows 9 and 10 are void of text for account.

https://camelot-py.readthedocs.io/en/master/user/advanced.html#specify-table-areas

这是我使用的.ipynb格式的代码。第一个块用于第一个按预期方式提取的表,第二个块用于第9页。

表格

tables= camelot.read_pdf(r'C:\PDFFilePath',pages='9',line_scale=40)
    tables[0].to_csv(r'Loans&Leases')
    camelot.plot(tables[0],kind ='contour')
    plt.show()

使用MatPlotLib,我可以看到Camelot正在正确检测第9页的表区域/网格。

plot table area

plot grid

这是PDF的Google云端硬盘链接

Call Report PDF

任何见识将不胜感激。

aiaiai5 回答:Camelot-py未在一行中检测到两行文本

您的验证码是正确的。

如果您尝试键入Input,这是正确的输出:

https://codesandbox.io/s/material-demo-xhzsw

因此,在导出为CSV时,您的问题是第10行和第11行中的换行符(\ n)。

解决方案可以是以下代码:

tables[0].df

使用tables= camelot.read_pdf(r'C:\PDFFilePath',pages='9',line_scale=40,strip_text='\n'),您可以删除不需要的字符(请参见enter image description here)。

现在,如果将表导出为CSV,则会得到: official documentation

本文链接:https://www.f2er.com/2661514.html

大家都在问