I have a simple Python snippet here which copies Macros Excel sheet into csvs. The snippet blows up for some odd reason. I used to run this snippet with Python 2.7 and had no problem with it. I recently downloaded Python 3.6. How can I fix this issue?
import csv import xlrd workbook = xlrd.open_workbook('P:/LFC Lots and Sales-NEW.xlsm') for sheet in workbook.sheets(): with open('{}.csv'.format(sheet.name), 'wb') as f: writer = csv.writer(f) writer.writerows(sheet.row_values(row) for row in range(sheet.nrows)) print ("Sheets copied") Traceback:
writer.writerows(sheet.row_values(row) for row in range(sheet.nrows)) TypeError: a bytes-like object is required, not 'str'