0

Please I'd like to ask you a question about opening an excel file. Now I'm trying to open it using this program:

data = pd.read_excel(r'C:\Users\Acer\Desktop\OffshoringData.xlsx')
print(data)

The problem is that I found the following error:

**xlrd.biffh.XLRDError: Excel xlsx file; not supported**

What should I do in this case, please??

Anas GOURZI
  • 1
  • 1
  • 1
  • run `pip install openpyxl xlsxwriter` from the command line. That should take care of the `xlrd` error. – MattDMo Aug 30 '21 at 13:47
  • Does this answer your question? [Pandas cannot open an Excel (.xlsx) file](https://stackoverflow.com/questions/65250207/pandas-cannot-open-an-excel-xlsx-file) – BigBen Aug 30 '21 at 13:51

2 Answers2

2

You need to use a different engine in your pandas.read_excel().

For security reasons xlrd no longer supports .xlsx files, but openpyxl still does.

So you would need to add engine='openpyxl' in your function.

Here's the documentation: https://pandas.pydata.org/docs/reference/api/pandas.read_excel.html

user14518362
  • 320
  • 4
  • 11
-1

This error is usually as a result of conflicting versions of the xlrd package and your excel version. Try installing a newer version of xlrd package (v2.0.1) which is able to handle .xlsx files. Seems the version of xlrd you are using is for older versions of excel files.

reference - xlrd python package

  • According of the author of the xlrd package, it does NOT support xlsx files in that version: https://stackoverflow.com/questions/65250207/pandas-cannot-open-an-excel-xlsx-file – XtianGIS Apr 05 '23 at 06:54