getting error...... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 370, in open_workbook biff_version = bk.getbof(XL_WORKBOOK_GLOBALS) File "C:\Python25\Lib\site-pack

John Machin sjmachin at lexicon.net
Mon Dec 8 11:54:01 CET 2008


On Dec 8, 6:48 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Fri, 05 Dec 2008 02:31:01 -0200, pk sahoo <prasannaksa... at gmail.com>  
> escribió:
>
>
>
> > hallo everybody,
> > when i am running the following command
>
> >>>> import xlrd
> >>>> book=xlrd.open_workbook("C:\\a.xls")
>
> > i am getting the following error..
>
> > *Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> >   File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 370, in
> > open_workb
> > ook
> >     biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
> >   File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 1323, in
> > getbof
> >     raise XLRDError('Expected BOF record; found 0x%04x' % opcode)
> > xlrd.biffh.XLRDError: Expected BOF record; found 0x3f3c*
>
> Looks like your a.xls file is not an Excel file (one of the formats  
> supported by xlrd).
> As 0x3f3c corresponds to the characters '<?' you probably have an XML file.

This can be verified easily by opening the file with a simple-minded
text editor (e.g. Notepad) ... if the first two lines are
"""
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
"""
then it's an Excel 2003 XML Spreadsheet that's been manually(?)
renamed from .xml to .xls.

The current xlrd release supports only the binary ("BIFF") format .xls
files created by Excel 3.0 to Excel 2003. The next release (due out
Real Soon Now) will support Excel 2.1 and 2.0 formats [don't ask].
Very soon after that will come support for Excel 2007 .xlsx which is a
bunch of XML files inside a ZIP file. Support for Excel 2003
"SpreadsheetML" is way down the to-do list.

If the OP wants to be able to read the file with xlrd:
(1) Open it with Excel 200[37] and save as a .xls file
or (2) rename it to .xml, start OpenOffice.org Calc, click on File,
click on Open, click on "Files of type", choose "Microsoft Excel 2003
XML (*.xml)" from the (long, unsorted) drop-down list, ..., and save
as etc etc. Gnumeric is not an option.

HTH,
John






More information about the Python-list mailing list