I've written a simple code in python using xlrd module that reads data from xlsx file and writes it to csv. When I try to write to csv with no fields I'm getting below error:
Error: need to escape, but no escapechar set
with reference to question 23296356 on so, I've tried setting quotechar to empty string to fix the error.But that did not fix the issue. What I'm I missing here? Below the code snippet that I've be running:
import xlrd
import csv
wb=xlrd.open_workbook('testfile.xlsx')
lisT = wb.sheet_names()
lLength = len(lisT)
for i in range(0,lLength-1):
sh = wb.sheet_by_name(lisT[i])
shfile = lisT[i]+".csv"
csvoutfile = open(shfile,'wb')
wr = csv.writer(csvoutfile, quoting=csv.QUOTE_NONE, quotechar='') #facing the issue here
for rownum in xrange(sh.nrows):
wr.writerow(sh.row_values(rownum))
csvoutfile.close()
print(sh.row_values(rownum))
for the first few rows, put those in a list, and add those to your question. Do test that the rows you add to your question actually reproduce the problem. If you add expected output too you'd have a complete minimal reproducible example. – Clarhe