Pandas.read_excel: Unsupported format, or corrupt file: Expected BOF record

Viewed 16865

I'm trying to use pandas.read_excel to read in .xls files. It succeeds on most of my .xls files, but then for some it errors out with the following error message:

Unsupported format, or corrupt file: Expected BOF record; found '\x00\x05\x16\x07\x00\x02\x00\x00'

I've been trying to research why this is happening to some, but not all files. The xlrd version is 1.0.0. I tried to manually read in with xlrd.open_workbook and I get the same result.

Does anyone know what file type, this BOF record is referring to?

3 Answers

I solved this problem loading it with pd.read_table (it loads everything into one column)

df = pd.read_table('path/to/xls_file/' + 'my_file.xls')

then I split this column with

df = df['column_name'].str.split("your_separator", expand=True)

Please check if you have given the right extension of the file either xlsx or csv. a wrong extension specified of the file may cause this issue.

Related