Issue with creating "xlsx" in Python by copying data from csv <p>I am trying to copy all the data in csv to excel "xlsx" file using python. I am using following code to do this:</p> <pre><code>from openpyxl import load_workbook import csv #Open an xlsx for reading wb = load_workbook(filename = "empty_book.xlsx") #Get the current Active Sheet ws = wb.get_active_sheet() #You can also select a particular sheet #based on sheet name #ws = wb.get_sheet_by_name("Sheet1") #Open the csv file with open("Pricing_Updated.csv",'rb') as fin: #read the csv reader = csv.reader(fin) #get the row index for the xlsx #enumerate the rows, so that you can for index,row in enumerate(reader): i=0 for row[i] in row: ws.cell(row=index,column=i).value = row[i] i = i+1 #save the excel file wb.save("empty_book.xlsx") </code></pre> <p>I found this code on <strong>SO</strong> itself and modified it to make it usable for my case. But this code is throwing <code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 0: ordinal not in range(128)</code> error for <code>ws.cell(row=index,column=i).value = row[i]</code> line.</p> <p>Please help me in resolving this issue.</p> <p><strong>Update</strong>: I tried using following code also to resolve the issue but came across <code>UnicodeDecode</code> error again for <code>ws.cell(row=rowx,column=colx).value = row[colx]</code> line:</p> <pre><code>for rowx,row in enumerate(reader): for colx, value in enumerate(row): ws.cell(row=rowx,column=colx).value = row[colx] </code></pre> <p><strong>Update 2</strong>: I tried using <code>xlwt</code> module also to copy the csv into xls (as it doesn't support xlxs) and again came across <code>UnicodeDecode</code> error, code which I used was:</p> <pre><code>import glob, csv, xlwt, os wb = xlwt.Workbook() for filename in glob.glob("Pricing_Updated.csv"): (f_path, f_name) = os.path.split(filename) (f_short_name, f_extension) = os.path.splitext(f_name) ws = wb.add_sheet(f_short_name) spamReader = csv.reader(open(filename, 'rb')) for rowx, row in enumerate(spamReader): for colx, value in enumerate(row): ws.write(rowx, colx, value) wb.save("exceltest7.xls") </code></pre>