Re: [Tutor] xls file
Kirk Bailey wrote: 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? You have discovered that the read-eval-print loop of the interpreter prints repr(obj). repr() is kind of a programmer's view of something; it often gives a representation of an object that you could use as input to the interpreter. Specifically, for strings, repr(someString) includes the quotes that you see printed in the interpreter. You will also sometimes see backslash escapes like '\xe9' in the repr() of a string. On the other hand, when you explicitly print a string, the characters of the string are output directly to the terminal (stdout). Any special characters are interpreted by the terminal rather that being escaped, and the quotes are not added. This is useful behaviour but it can be very confusing to newcomers. Kent PS Please use Reply All to reply to the list. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] xls file
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.17001, number:11.0, number:0.5, number:6.0, number:0.28003, number:29.0, number:0.080002] 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. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] xls file
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? Kirk Bailey wrote: Ii want to read a xls file and use the data in part of it. What module would help make sense of one? -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] xls file
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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] xls file
Kirk Bailey [EMAIL PROTECTED] wrote Ii want to read a xls file and use the data in part of it. What module would help make sense of one? If the data is straighforward you might find it easier to save it as a csv file first. But otherwise there is a module called pyexcelerator (I think?) which can work with Excel 97 and 95 formats. http://sourceforge.net/projects/pyexcelerator HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] xls file
Alan Gauld [EMAIL PROTECTED] wrote: Kirk Bailey wrote Ii want to read a xls file and use the data in part of it. What module would help make sense of one? If the data is straighforward you might find it easier to save it as a csv file first. But otherwise there is a module called pyexcelerator (I think?) which can work with Excel 97 and 95 formats. http://sourceforge.net/projects/pyexcelerator HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Try this. I found it on the web. (xlrd package) I think you don't even need windows to use these. I tried it and it works well. http://www.lexicon.net/sjmachin/xlrd.htm http://cheeseshop.python.org/pypi/xlrd - Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] xls file
Really? What are you having trouble with? I have used pyexcelerator under Windows without problems. -- John. On 16/08/07, Kirk Bailey [EMAIL PROTECTED] wrote: looks good. works bad; this is a windows workplace. ouch. Advice please (other than change operating systems)? John Fouhy wrote: On 15/08/07, Kirk Bailey [EMAIL PROTECTED] wrote: Ii want to read a xls file and use the data in part of it. What module would help make sense of one? I have used pyExcelerator in the past. You can find it with google. Sample usage: import pyExcelerator workbook = pyExcelerator.parse_xls('filename.xls') worksheet = workbook['Sheet 1'] # print cells A1 and B1 print worksheet[(0,0)], worksheet[(0,1)] -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor