Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas cannot open an Excel (.xlsx) file

People also ask

Why does xlrd not support Xlsx?

xlsx files was removed from xlrd due to a potential security vulnerability.

How do I fix XLRDError excel XLSX not supported?

Solution 1 — Upgrading Pandas To the Latest Version You can solve the xlrd. biffh. XLRDError: Excel xlsx file; not supported error by upgrading the Pandas version to the latest version.

Can pandas read an open excel file?

Read an Excel file into a pandas DataFrame. Supports xls , xlsx , xlsm , xlsb , odf , ods and odt file extensions read from a local filesystem or URL. Supports an option to read a single sheet or a list of sheets. Any valid string path is acceptable.


As noted in the release email, linked to from the release tweet and noted in large orange warning that appears on the front page of the documentation, and less orange but still present in the readme on the repo and the release on pypi:

xlrd has explicitly removed support for anything other than xls files.

This is due to potential security vulnerabilities relating to the use of xlrd version 1.2 or earlier for reading .xlsx files.

In your case, the solution is to:

  • make sure you are on a recent version of pandas, at least 1.0.1, and preferably the latest release.
  • install openpyxl: https://openpyxl.readthedocs.io/en/stable/
  • change your pandas code to be:
    pandas.read_excel('cat.xlsx', engine='openpyxl')
    

Edit: Currently, pandas >= 1.2 addresses this issue. (Release Notes)


The latest version of xlrd (2.0.1) only supports .xls files.

If you are prepared to risk potential security vulnerabilities, and risk incorrect parsing of certain files, this error can be solved by installing an older version of xlrd.

Use the command below in a shell or cmd prompt:

pip install xlrd==1.2.0