Hello. I am trying to open an .xls (excel) file using xlrd, but an error message occurs when I open the workbook.
I can open any other .xls file made by myself (either by MS Excel 2003 SP3 in Windows Vista or by OpenOffice 2.0 in Debian) using the *open_workbook*function: wb = xlrd.open_workbook('myworkbook.xls') but when I try to open a file from one specific site, I get the error message: In [2]: wb = xlrd.open_workbook('balanco.xls') WARNING *** file size (81192) not 512 + multiple of sector size (512) WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero --------------------------------------------------------------------------- struct.error Traceback (most recent call last) /home/oikawa/DB/<ipython console> /usr/lib/python2.4/site-packages/xlrd/__init__.py in open_workbook(filename, logfile, verbos ity, pickleable, use_mmap, file_contents, encoding_override, formatting_info) 380 bk.parse_globals() 381 else: --> 382 bk.parse_globals() 383 bk.get_sheets() 384 bk.nsheets = len(bk._sheet_list) /usr/lib/python2.4/site-packages/xlrd/__init__.py in parse_globals(self) 1309 self.handle_name(data) 1310 elif rc == XL_PALETTE: -> 1311 self.handle_palette(data) 1312 elif rc == XL_STYLE: 1313 self.handle_style(data) /usr/lib/python2.4/site-packages/xlrd/formatting.py in handle_palette(book, data) 550 "PALETTE record with %d colours\n", n_colours) 551 fmt = '<xx%di' % n_colours # use i to avoid long integers --> 552 colours = unpack(fmt, data) 553 assert book.palette_record == [] # There should be only 1 PALETTE record 554 # a colour will be 0xbbggrr error: unpack str size does not match format I ran the xlrd in both Windows Vista / Python 2.5 and Debian / Python 2.4.4 and got the same problem, so I suppose there is something wrong with the .xls files (which can be downloaded at www.fundamentus.com.br --> "Dados Históricos" menu --> "Balancos em Excel" --> choose any company). However, I need the files in order to create my database system. Actually I want to build all companies' informations in a mySQL database, and the fastest and easiest way I found is to download .xls files, to get the data using xlrd-Python and to add them in the mySQL database. Any sugestions for both questions? Thanks in advance. Best regards, Fabio Oikawa
-- http://mail.python.org/mailman/listinfo/python-list