-1

When running this Python code:

import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
import unicodedata
import codecs

DataFile=pd.read_excel('indata.xlsx')#,dtype={'text': unicode})

for Rownumber in range (0,7):# 2? til 23761?
 print('rownumber: ', Rownumber)
 ColumnF=str((DataFile.iloc[Rownumber,5]))
 print('ColumnF: ', ColumnF)        
print('EOF')

I get the following error:

('rownumber: ', 0)
Traceback (most recent call last):
  File "example.py", line 13, in <module>
    ColumnF=str((DataFile.iloc[Rownumber,5]))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6' in position 11: ordinal not in range(128)

any idea how to make Python read xlsx containing non-ascii utf8 caharacters in xlsx?

1 Answers1

0

Try opening the excel with an encoding:

EX:

DataFile=pd.read_excel('indata.xlsx', encoding = 'utf8')
Rakesh
  • 81,458
  • 17
  • 76
  • 113