I got an error:
NameError: name 'sheet' is not defined .I wanna parse excel and print the content.
My wrote codes:
class ReadData():
def __init__(self, sheet_path):
self.book = xlrd.open_workbook(sheet_path)
self.sheet = self.book.sheet_by_index(1)
self.companies = []
def read(self):
for row_index in range(2, sheet.nrows):
rows = sheet.row_values(row_index)
print(rows)
x = ReadData('./data/excel1.xlsx')
x.read()
I really cannot understand why this error happens.Should I add something to use init ?How can I fix this?