[英]TypeError: list indices must be integers or slices, not Table
I'm trying to extract some tables in a big pdf with camelot.我正在尝试使用 camelot 提取大 pdf 中的一些表格。 This is working but now I want to extract every single table from the TableList renaming the tables eachtime.
这是可行的,但现在我想从 TableList 中提取每个表,每次都重命名表。 Here is an extract from my code :
这是我的代码的摘录:
tables = camelot.read_pdf("file.pdf", pages = "1")
table = ""
for i in tables:
globals()['table'+str(i)] = tables[i]
And I have this error:我有这个错误:
TypeError: list indices must be integers or slices, not Table
TypeError:列表索引必须是整数或切片,而不是表
In this case I have 2 tables in the first page in the final issue I have hundreds pages and tens of tables.在这种情况下,我在最后一期的第一页中有 2 个表格,我有数百页和数十个表格。
tables = camelot.read_pdf("file.pdf", pages = "1")
table = ""
for i in tables:
globals()['table'+str(i)] =i
Try this one.试试这个。 Because your
i
now is an table object.因为你的
i
现在是一个表对象。
incase you want indexing.如果你想要索引。
tables = camelot.read_pdf("file.pdf", pages = "1")
table = ""
for i in range(len(tables)):
globals()['table'+str(i)] =tables[i]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.