<div dir="ltr">Hello.<br><br>I am trying to open an .xls (excel) file using xlrd, but an error message occurs when I open the workbook.<br><br>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 <i>open_workbook</i> function:<br>
<pre style="margin-left: 40px;" class="prettyprint"><code class="code">wb = xlrd.open_workbook('myworkbook.xls')</code></pre>but when I try to open a file from one specific site, I get the error message:<br><br><div style="margin-left: 40px;">
In [2]: wb = xlrd.open_workbook('balanco.xls')<br><br>WARNING *** file size (81192) not 512 + multiple of sector size (512)<br>WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero<br>---------------------------------------------------------------------------<br>
struct.error                                     Traceback (most recent call last)<br><br>/home/oikawa/DB/<ipython console><br><br>/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)<br>
    380         bk.parse_globals()<br>    381     else:<br>--> 382         bk.parse_globals()<br>    383         bk.get_sheets()<br>    384     bk.nsheets = len(bk._sheet_list)<br><br>/usr/lib/python2.4/site-packages/xlrd/__init__.py in parse_globals(self)<br>
   1309                 self.handle_name(data)<br>   1310             elif rc == XL_PALETTE:<br>-> 1311                 self.handle_palette(data)<br>   1312             elif rc == XL_STYLE:<br>   1313                 self.handle_style(data)<br>
<br>/usr/lib/python2.4/site-packages/xlrd/formatting.py in handle_palette(book, data)<br>    550             "PALETTE record with %d colours\n", n_colours)<br>    551     fmt = '<xx%di' % n_colours # use i to avoid long integers<br>
--> 552     colours = unpack(fmt, data)<br>    553     assert book.palette_record == [] # There should be only 1 PALETTE record<br>    554     # a colour will be 0xbbggrr<br><br>error: unpack str size does not match format<br>
</div><br>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 <a href="http://www.fundamentus.com.br">www.fundamentus.com.br</a> --> "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.<br>
<br>Best regards,<br>Fabio Oikawa<br><br><br></div>