我想遍历所有非空的 Excel 表格以获取标题。我必须为此使用 PyExcel。这是我的代码:
import pyexcel as pe
book = pe.get_book(file_name="Mydata.xlsx")
j=0
print(j)
for j in range(100):
for item in book.sheet_by_index(j):
sheet = pe.get_sheet(file_name="Mydata.xlsx")
sheetheaders= sheet.row_at(0)
header_list = [i for i in sheetheaders if i != '' ]
print(header_list)
j=j+1
谁能帮助我告诉我如何迭代它而不会出现以下错误?
Traceback (most recent call last):
line 11, in <module>
for sheet in book[i]:
TypeError: 'NoneType' object is not iterable
谢谢!