Python Pandas can't read .xls file though engine is xlrd

Question:

have a 1 GB excel sheet with xls format (old excel), and I can’t read it with pandas

df = pd.read_excel("filelocation/filename.xls",engine = "xlrd")

XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'<html>rn'

and if removed the engine it sends this error

ValueError: Excel file format cannot be determined, you must specify an engine manually

any advice will be appreciated thanks

Asked By: Gojoe

||

Answers:

df = pd.read_excel("file location/filename.xls",engine = "xlrd")

remove the "engine"

df = pd.read_excel("file location/file name.xls")

Answered By: Harlan Enciso

One of these options should work:

data = pandas.read_table(r"filelocation/filename.xls")

or

data = pandas.read_html("filelocation/filename.xls")

Otherwise, try another HTML parse, I agree with @AKX, this doesn’t look like an excel file.

Answered By: John85
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.