xlrd: error open_workbook
M.-A. Lemburg
mal at egenix.com
Tue Jul 29 04:23:34 EDT 2008
On 2008-07-28 22:22, Fabio Oikawa wrote:
> 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
This looks like a broken XLS file.
In any case, you're probably better off asking this question on
the python-excel mailing list:
http://groups.google.com.au/group/python-excel?lnk=li&hl=en
You might also want to try pyExcelerator:
http://sourceforge.net/projects/pyexcelerator
> ---------------------------------------------------------------------------
> 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.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Jul 29 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-list
mailing list