我正在使用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中的这些特定区域,但忽略之后的空区域。需要能够以有序的方式使用提取的数据。
也可以接受任何其他建议
提亚
发布于 2019-01-08 16:34:26
也许选项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.发布于 2020-04-16 08:01:31
我也有同样的问题!这不是一个完美的解决方案,但我相信您可以通过将可能导致空表的特定table_area调用分离到它自己的pdf_read调用中来解决这个问题。这样,您就可以按照上面的建议进行操作,只需用try_catch块围绕pdf_read即可。这会给你带来你想要的健壮性。
https://stackoverflow.com/questions/54004215
复制相似问题