Search code examples
pythonxlrd

Error reading excel file using XLRD and Python


I'm reading from an excel file every 30 seconds using XLRD. However I keep getting error messages from XLRD...

  File "C:\Users\Administrator\Desktop\New Folder\final_30sec.py", line 22, in odds
  book = open_workbook('excel.xls')
  File "C:\Python27\lib\site-packages\xlrd-0.9.0-py2.7.egg\xlrd\__init__.py", line 443, in open_workbook
  ragged_rows=ragged_rows,
  File "C:\Python27\lib\site-packages\xlrd-0.9.0-py2.7.egg\xlrd\book.py", line 90, in open_workbook_xls 
  ragged_rows=ragged_rows,
  File "C:\Python27\lib\site-packages\xlrd-0.9.0-py2.7.egg\xlrd\book.py", line 619, in biff2_8_load 
  cd = compdoc.CompDoc(self.filestr, logfile=self.logfile)
  File "C:\Python27\lib\site-packages\xlrd-0.9.0-py2.7.egg\xlrd\compdoc.py", line 234, in __init__
  _build_family_tree(dirlist, 0, dirlist[0].root_DID) # and stand well back ..
  File "C:\Python27\lib\site-packages\xlrd-0.9.0-py2.7.egg\xlrd\compdoc.py", line 71,  in _build_family_tree
  _build_family_tree(dirlist, parent_DID,    dirlist[child_DID].right_DID)
  File "C:\Python27\lib\site-packages\xlrd-0.9.0-py2.7.egg\xlrd\compdoc.py", line 68, in _build_family_tree

Would anyone happen to know what causes this error and how to avoide it...?


Solution

  • Without an error in your question it is guesswork what is going wrong. But since this happens in open_workbook(), I suggest you first check if the file you are using is correct by opening it in Excel (or OpenOffice).

    If it opens in Excel, then make a minimal .xls file that your application could work with from scratch. If that fails the open_workbook() call as well you should consider posting the file and details on how you made such a file, including which version of which software you are using, operating system and version.

    If it doesn't work in Excel it is unlikely to have to do with a problem in xlrd.