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 21:02:07 EST 2008


On Dec 9, 12:19 pm, JodyGnumeric <jody.goldb... at gmail.com> wrote:
> On Dec 8, 5:54 am, John Machin <sjmac... at lexicon.net> wrote:
>
>
>
> > 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
>
> Gnumeric can read this format. 'MS Excel (tm) 2003 SpreadsheetML'

[Gnumeric 1.9.1 on Windows XP]

I'm sorry; I thought I'd exhausted every possible way of trying to
open it. After looking at the file open dialogue box again, I've
spotted the "Advanced" button. Here is what you need to do:

Have the file named whatever.xls. Click on File / Open , navigate to
correct directory, click on Advanced, choose 'MS Excel (tm) 2003
SpreadsheetML' from the File-type drop-down list, choose the file,
click on OK. Anything else (Simple (non-Advanced), naming it
whatever.xml, ...) produces no response, yes that's zero bits of
information, not even a Bzzzzt! noise :-(

*AND* when it does open up, a date cell defined by
  <Style ss:ID="s21">
   <NumberFormat ss:Format="Short Date"/>
  </Style>
...
<Cell ss:StyleID="s21"><Data
ss:Type="DateTime">1999-12-31T00:00:00.000</Data></Cell>

is displayed as "00ort 31at1999" :-(



More information about the Python-list mailing list