简体   繁体   English

TypeError:列表索引必须是整数或切片,而不是表

[英]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.

相关问题 TypeError:列表索引必须是整数或切片,而不是列表” - TypeError: list indices must be integers or slices, not list" “TypeError:list indices必须是整数或切片,而不是str” - “TypeError: list indices must be integers or slices, not str” TypeError:列表索引必须是整数或切片,而不是元组? - TypeError: list indices must be integers or slices, not tuple? TypeError:列表索引必须是整数或切片,而不是LpVariable - TypeError: list indices must be integers or slices, not LpVariable TypeError:列表索引必须是整数或切片,而不是 str - TypeError: List indices must be integers or slices and not str TypeError:列表索引必须是整数或切片,而不是标签 - TypeError: list indices must be integers or slices, not Tag TypeError:列表索引必须是整数或切片,而不是ObjectId - TypeError: list indices must be integers or slices, not ObjectId TypeError:列表索引必须是整数或切片,而不是Slot - TypeError: list indices must be integers or slices, not Slot TypeError:列表索引必须是整数或切片,而不是字符串 - TypeError: list indices must be integers or slices, not string “TypeError:列表索引必须是整数或切片,而不是浮点数” - “TypeError: list indices must be integers or slices, not float”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM