> On 10/10/2009 3:07 PM, Anthony Graddy wrote:
> > Hi,
> Hi Anthony, and welcome to the group.
> > I uploaded three files to the group.
> > I need to process an "Excel file" (maybe it's something else?) that I
> > downloaded from this website:
> >http://infopost.panhandleenergy.com/InfoPost/jsp/frameSet.jsp?pipe=pepl
> > When I try to open the original.xls file, I get this warning:
> > WARNING *** file size (80900) not 512 + multiple of sector size (512)
> > If I open the file in Open Office, it opens just fine and all of the
> > data appears correct. Is there a way for me to get xlrd to open it
> > too?
> Yes, the way that you tried. WARNING != error.
> > I'm able to resave the file in Open Office as a Microsoft Excel
> > 97/2000/XP file (the resaved.xls file) and it opens just fine in xlrd.
> > Any ideas what the problem is with the original file
> It has 4 extra bytes after the normal payload. Inspection with a hex
> editor shows that they are "\r\n\r\n". No other apparent damage. If you
> have the appropriate relationship with the source, you might like to
> hint gently that they may like to avoid having crazy people in the
> pipeline between the file creation and its appearence on the web.
> > (there is
> > obviously a file size difference when it gets resaved)?
> That difference often happens. It's not a cause for concern.
> > Anyway I can
> > access it without having to open and resave in Open Office?
> Just ignore the warning. If you don't like the warning coming out, you
> could write a small wrapper function that opens the file with builtin
> open(..., mode='rb'), reads it into say "buff" and checks the filesize:
> (a) size % 512 == 0: use open_workbook(..., file_contents=buff)
> (b) (size % 512 == 4) and buff.endswith("\r\n\r\n"): use
> open_workbook(..., file_contents=buff[:-4])
> (c) otherwise they're doing something different ... better check it out.
> Cheers,
> John