我想从多页pdf中提取表格。由于表属性,我需要对read_pdf使用flavor='stream'和table_areas属性,以便正确检测我的表。我的问题是表在每个页面上的位置是不同的(第一个页面有一个地址头,而另一个页面没有)
我尝试为read_pdf函数提供几个方面,如下所示:
camelot.read_pdf(file, pages='all', flavor='stream', table_areas=['60, 740, 580, 50','60, 470, 580, 50'])但是这个结果是每页有2个表。如何为每个页面分别指定table_areas?
我也尝试过多次使用不同的pages/table_areas运行read_pdf,但是我不能将几个结果附加在一起得到一个单独的对象:
tables = camelot.read_pdf(file, pages='1', flavor='stream', table_areas=['60, 470, 580, 50'])
tables.append(camelot.read_pdf(file, pages='2-end', flavor='stream', table_areas=['60, 740, 580, 50']))给出一个错误,因为append不是生成tables的方法
有没有一种方法可以连接read_pdf函数的几次调用结果?
发布于 2021-07-12 16:34:32
实际上,正如您所注意到的,不能直接将项添加到TableList对象。
相反,您可以通过以下方式操作TableList _tables属性(_tables是一个列表):
my_tables = camelot.read_pdf(file, pages='1', flavor='stream', table_areas=['60, 470, 580, 50'])
my_tables._tables.append(camelot.read_pdf(file, pages='2-end', flavor='stream', table_areas=['60, 740, 580, 50']))现在my_tables应该由两个表组成。
https://stackoverflow.com/questions/68338012
复制相似问题