[Tutor] xls file

Kent Johnson kent37 at tds.net
Mon Aug 20 20:53:03 CEST 2007


Kirk Bailey wrote:
> ok, I installed XLRD and can load a xls file; it works quite well BTW. Now 
> it is returning Unicode objects. I need to strip that to a simple string 
> value. Is there a recommended way or module for handling Unicode objects?

What kind of characters are in the Excel file? What do you want to do 
with non-ascii characters?

Some options:
unicodeData.decode('ascii')  # Will choke if any non-ascii characters
unicodeData.decode('ascii', 'ignore') # Will throw away non-ascii characters
unicodeData.decode('ascii', 'replace') # Will replace non-ascii 
characters with '?'

Also of interest:
http://www.crummy.com/cgi-bin/msm/map.cgi/ASCII%2C+Dammit
http://groups.google.com/group/comp.lang.python/msg/159a41b3e6bae313?hl=en&

Kent


More information about the Tutor mailing list