I want to iterate through all the non empty sheets of Excel to get the headers. I must use PyExcel for that.Here is my code:
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
Can anyone help me by telling how do I iterate it without getting following error?
Traceback (most recent call last):
line 11, in <module>
for sheet in book[i]:
TypeError: 'NoneType' object is not iterable
Thank you!
ito 0.sheeheadersisNone. Are you sure you didn't misspellshee*t*headers? Where is this variable defined? Did you mean maybeheader_list = [header for header in sheet]?book[i]? Can you paste your whole code at once?