0

I'm trying to make a DataFrame out of this xls file, but keep getting errors:

import pandas as pd
from pandas import *
xls = pd.ExcelFile('/home/nick/LA_County15K-50K.xls')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pandas/io/excel.py", line 136, in __init__
  self.book = xlrd.open_workbook(io)
  File "/usr/lib/python2.7/dist-packages/xlrd/__init__.py", line 435, in open_workbook
  ragged_rows=ragged_rows,
  File "/usr/lib/python2.7/dist-packages/xlrd/book.py", line 91, in open_workbook_xls
  biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
  File "/usr/lib/python2.7/dist-packages/xlrd/book.py", line 1258, in getbof
  bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
  File "/usr/lib/python2.7/dist-packages/xlrd/book.py", line 1252, in bof_error
  raise XLRDError('Unsupported format, or corrupt file: ' + msg)
  xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;   found   '\r\n      '

I am using Linux Mint. Why am I getting this error and what can I do to fix it so I can make a DataFrame, thanks?

RomanHotsiy
  • 4,978
  • 1
  • 25
  • 36
nickshoe
  • 17
  • 8
  • possible duplicate of [python xlrd unsupported format, or corrupt file.](http://stackoverflow.com/questions/9623029/python-xlrd-unsupported-format-or-corrupt-file) – RomanHotsiy Jul 21 '14 at 06:26
  • Are you sure this is an Excel sheet and not a CSV with the `.xls` extension? Type `file $HOME/LA_County15K-50K.xls` from a terminal and report back the output. – Burhan Khalid Jul 21 '14 at 06:27
  • This is the output I got: nick@nick-Inspiron-5721 ~ $ file $HOME/LA_County15K-50K.xls /home/nick/LA_County15K-50K.xls: HTML document, ASCII text, with very long lines, with CRLF line terminators – nickshoe Jul 21 '14 at 07:59

0 Answers0