I would like to convert all the csv files in a directory to xls files. Nick T posted this code here How to batch convert .csv to .xls/xlsx
import os import glob import csv import xlwt # from http://www.python-excel.org/ for csvfile in glob.glob(os.path.join('.', '*.csv')): wb = xlwt.Workbook() ws = wb.add_sheet('data') with open(csvfile, 'rU') as f: reader = csv.reader(f) for r, row in enumerate(reader): for c, val in enumerate(row): ws.write(r, c, val) wb.save(csvfile + '.xls')
However when I run this I get an error coming from the last line.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
Anyone know how I can get rid of this? I am working in Terminal on a Mac.