A question on Encoding and Decoding.

kath nitte.sudhir at gmail.com
Mon Nov 13 13:37:32 EST 2006


Hi all,

Platform:            winxp
Version:             Python 2.3

I have a task of reading files in a folder and creating an one excel
file with sheets, one sheet per file, with sheet named as filename. I
am facing problem in handling special characters. I am using XLRD and
XLW package to read/write  from/to file. But facing problem in handling
special characters. I am getting encode error.

UnicodeDecodeError 'ascii' codec can't encode character u'\xdf' in
position 19: ordinal not in range(128)
row:  76

the cell value at rowx = 76, colx = 0  is
'Activest-Aktien-Großbritannien'

I used Latin-1 encoding, but after the file is created I get an error
'Unable to read the file'.

When I get the exception I want to format the string so that I can use
it to write to a file and also query database.

Can anybody guide how to solve this problem. what encoding I should
use, and after wring to file I should the same special character.

Also python IDLE is able to output the same character corretly when I
say print and why not I?


Any suggestions would be greatly appreciated.

thanks.
regards,
kath.




More information about the Python-list mailing list