Hello Guys How are you all ? Hope you all are fine. I am trying to read macro enabled excel work sheet using pandas.read_excel
with xlrd library. But I am facing xlrd.biffh.XLRDError: Excel xlsx file; not supported this error.
So here I am come with all possible solution .
What is Error
When you try to read macro enabled excel work sheet using pandas.read_excel
with xlrd library its through error like below
2020-12-12T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR] df1=pd.read_excel(os.path.join(APP_PATH, os.path.join("Data", "aug_latest.xlsm")),sheet_name=None)
2020-12-12T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR] return open_workbook(filepath_or_buffer)
2020-12-12T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR] File "/home/vcap/deps/0/python/lib/python3.8/site-packages/xlrd/__init__.py", line 170, in open_workbook
2020-12-12T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR] raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
2020-12-12T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR] xlrd.biffh.XLRDError: Excel xlsx file; not supported
Solutions
Question : How to Solve xlrd.biffh.XLRDError: Excel xlsx file; not supported ?
Answer : The latest version of xlrd(2.01) only supports .xls files. Installing the older version 1.2.0 worked for me to open .xlsx files.
Solution 1
- Installing the older version, 1.2.0, worked for me to open .xlsx files.
Solution 2
- 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
Solution 3
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:
- install openpyxl: https://openpyxl.readthedocs.io/en/stable/
- change your pandas code to be:
pandas.read_excel(‘cat.xlsx’, engine=’openpyxl’)
Solution 4
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
Summery
So Hope This Above 3 Solution Will Work For You Too. So it’s all About xlrd.biffh.XLRDError: Excel xlsx file; not supported error. Hope this tutorial helped you a lot. Comment below Your thoughts and your queries. And Also Comment on your suggestion here.
Thank you for sharing this.
Welcome Abel !
thanks for the info, it saved my time.
Welcome sreenivas ji
This is amazing, thank you for sharing this!!
Welcome James !
awesome, this works for me
Thank You For Your Response Roberto
engine=’openpyxl’ works for me
Thank You For Your Response Chinmay Kashikar
Thank you for sharing
Much appreciated. Your solution resolved my concern.
Thank you for the info. Any idea with the error, as i try to open an xlsx file.
i get the below error:
XLRDError: ZIP file contents not a known type of workbook
Thank you.
Brother
import numpy as np
import pandas as pd
import os
datas=pd.read_excel('transactions.xlsx')
data
Is This Above Worked for you ?? If above code not working for you then might be there is something wrong with the Excel file
solution5:
pip install pyexcel-xls
Thank you very much for this solution, it save my day 😉
Thank you.
pip install xlrd==1.2.0
It works for me.
But if I still want to use the lastest version, is there any solution?
Thank you.
pip install xlrd==1.2.0, works for me.
Solution 4 Worked For Me. Thank You Brother