【问题标题】:Headers are not getting extracted from PDF while extracting the table data from PDF using camelot使用 camelot 从 PDF 中提取表格数据时,没有从 PDF 中提取标题
【发布时间】:2019-04-11 17:28:01
【问题描述】:

我正在使用 camelot 进行表格数据提取,但是标题没有被提取为 PDF 的一部分。

附加目标 下面的PDF链接和目标表在第3页和第4页,需要提取。

https://drive.google.com/file/d/1xniTIwpnNIdA_k4xvEARlVH97Lk-K2Yr/view?usp=sharing

其中一个表格如下所示

我看过 camelot 文档,我认为问题与 “检测短线”

有关

https://camelot-py.readthedocs.io/en/master/user/advanced.html#detect-short-lines

但无法通过调整 line_size_scaling 参数来解决问题。

请帮忙。

【问题讨论】:

    标签: pdf-scraping python-camelot


    【解决方案1】:

    我使用$ camelot -p 3 lattice -plot contour 007.pdf 在第 3 页上绘制了检测到的表格边界。看起来 Camelot 在检测到的表格边界 [bug 1] 中不包括标题行(见下图)。然后我尝试将table_areas 关键字参数与flavor='lattice' 一起使用,但它没有包含指定表格边界中的行[bug 2]。我在问题跟踪器中添加了这些#200#201

    您仍然可以将table_areas 关键字参数与flavor='stream' 一起使用来获取表格。

    使用 CLI:$ camelot -p 3 --output 007.csv --format csv stream -T 60,770,520,400 007.pdf

    使用 API:tables = camelot.read_pdf('007.pdf', pages='3', flavor='stream', table_areas=['60,770,520,400'])

    您可以使用此处描述的步骤找到表格边界坐标:https://camelot-py.readthedocs.io/en/master/user/advanced.html#visual-debugging

    希望有帮助!

    【讨论】:

    • 嗨@Vinayak,感谢您的回复。我还绘制了表格边界并得到了相同的结果,因为标题不是表格的一部分。将跟踪错误编号。
    • 我无法创建标签“python-camelot”,因为我没有足够的积分来做这件事,请您创建“python-camelot”标签。由于我使用的是 camelot 所以可能还有其他问题。
    • 我可以看到标签。如果您觉得这个答案有帮助,请采纳,谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2022-10-09
    相关资源
    最近更新 更多