I know this is a recurrent subject but I'm facing a encoding/decoding error when trying to parse an Excel file (.xlsx) opened with xlrd
value = sheet.cell(row,col).value
value = value.decode('utf-8') // also tried cp1252 and iso-8859-15
WARNING: 'ascii' codec can't encode character u'\xe9' in position xx: ordinal not in range(128)
xlrd doc says that From Excel 97 onwards, the text in Excel spreadsheets has been stored as Unicode. So decoding should not even be necessary.
Any idea what should be done ?
P.S. My Excel file has some é and à inside.
Still using Python 2? :(
If what you're trying to do is convert from unicode
to UTF-8 encoded str
, you need to value.encode('utf-8')
, not decode
.