gpt4 book ai didi

Python-Camelot 提取空表

转载 作者:太空宇宙 更新时间:2023-11-03 21:23:49 24 4
gpt4 key购买 nike

我正在使用 Camelot 通过以下命令提取 PDF 的多个部分。

cgl_section = camelot.read_pdf(filename, flavor='stream', 
table_areas=['35,490,155,483', '53,480,110,470', '117,480,155,470',
'38,469,106,456', '39,454,105,445', '38,430,155,420',
'38,418,77, 410'])

当 PDF 实际上包含这些区域中的数据时,此方法运行良好。但我并不期望解析的每个 PDF 中都有数据,有些会返回空。当返回的数据不是表而只有一列时,出现以下错误。

UserWarning: No tables found in table area 1

ValueError: min() arg is an empty sequence

我需要一种方法来提取所有 PDF 中的这些特定区域,但忽略后面的空白区域。需要能够有序地使用提取的数据。

也欢迎任何其他建议

TIA

最佳答案

也许选项 table_regions(0.7 中引入)可以帮助您。

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

When table_regions is specified, Camelot will only analyze the specified regions to look for tables.

关于Python-Camelot 提取空表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54004215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com