I am trying to convert .xlsx to .csv. From xls to csv converter I am hoping to use this code:
import xlrd
import csv
wb = xlrd.open_workbook('Book123.xlsx')
sh = wb.sheet_by_index(0)
your_csv_file = open('your_csv_file.csv', 'w')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in range(sh.nrows):
wr.writerow(sh.row_values(rownum))
your_csv_file.close()
However, when I am trying to execute sh = wb.sheet_by_index(0)
I cannot find the sheet.
I also tried wb.sheet_by_name('Sheet1')
gets error code : XLRDError: No sheet named <'Sheet1'>
. In short, for some reasons, I cannot find any sheets in the file. Can anyone help me reslove this issue?
Thank you very much!