[Tutor] xls file
Kirk Bailey
deliberatus at verizon.net
Thu Aug 23 05:23:03 CEST 2007
here s one line from a spreadsheet, as saved in python;
[text:u'Bob Dobbs', number:0.0, number:1.0, text:u'n/0!', number:0.0,
number:0.0, number:0.0, number:0.0, number:0.0, number:0.0]
[text:u'Connie Dobbs', number:22.0, number:4.0, number:0.17000000000000001,
number:11.0, number:0.5, number:6.0, number:0.28000000000000003,
number:29.0, number:0.080000000000000002]
I extracted cell 0,0 and it is
>>> x
u'Bob Dobbs'
>>>
So I did this:
>>> str(x)
'Bob Dobbs'
>>>
>>> b[1:-1]
'ob Dobb'
>>>
oops... well,then i did this
>>> print b
Bob Dobbs
>>>
which is as I need it. any use to the rest of the list?
Kent Johnson wrote:
> 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
>
>
--
Salute!
-Kirk Bailey
Think
+-----+
| BOX |
+-----+
knihT
Fnord.
More information about the Tutor
mailing list