0

Also there existing already several questions on this topic with solutions:

Pandas cannot open an Excel (.xlsx) file

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

I am working with python 3.9 in visual studio code with the packages:

xlrd                    2.0.1
pandas                  1.1.5
openpyxl                3.1.2

when I am running the command:

mapping = pd.read_excel('mapping/mapping.xlsx', dtype=str, engine='openpyxl') 

or:

mapping = pd.read_excel('mapping/mapping.xlsx', dtype=str) 

it both gives the error:

XLRDError: Excel xlsx file; not supported

The solutions provided in the similar questions don't help me here.

PV8
  • 5,799
  • 7
  • 43
  • 87
  • specifying the engine should have worked, can you confirm that the changes were saved before testing? As a workaround, you could downgrade `xlrd` to a version where `xlsx` is supported, but it should be noted that the author of `xlrd` explicitly discourages doing so in [a comment under this answer](https://stackoverflow.com/a/65251042/21169587) for security reasons. – Shorn May 03 '23 at 08:44
  • the changes are saved before testing, and I don't want to downgrade my xlrd version – PV8 May 03 '23 at 08:53
  • Have you tried only `pd.ExcelFile('mapping/mapping.xlsx', engine='openpyxl')` and then parse it to `str`? Related [stackoverflow: ExcelFile vs. read_excel in pandas](https://stackoverflow.com/questions/26474693/excelfile-vs-read-excel-in-pandas). – Memristor May 03 '23 at 09:43
  • @Memristor same error – PV8 May 03 '23 at 09:47
  • If you are trying this on a jupyter notebook maybe you should restart the kernel, just to rule out previous attempts. – Memristor May 03 '23 at 09:54

1 Answers1

0

Updated to pandas 1.4.2 solved the error with the command:

pip install --upgrade pandas==1.42
PV8
  • 5,799
  • 7
  • 43
  • 87