Pandas cannot open an Excel xlsx file

0 votes

Please see my code below:

import pandas
df = pandas.read_excel('cat.xlsx')

After running that, it gives me the following error:

Traceback (most recent call last):
  File "d:\OneDrive\桌面\practice.py", line 4, in <module>
    df = pandas.read_excel('cat.xlsx')
  File "D:\python\lib\site-packages\pandas\util\_decorators.py", line 296, in wrapper
    return func(*args, **kwargs)
  File "D:\python\lib\site-packages\pandas\io\excel\_base.py", line 304, in read_excel
    io = ExcelFile(io, engine=engine)
  File "D:\python\lib\site-packages\pandas\io\excel\_base.py", line 867, in __init__
    self._reader = self._engines[engine](self._io)
  File "D:\python\lib\site-packages\pandas\io\excel\_xlrd.py", line 22, in __init__
    super().__init__(filepath_or_buffer)
  File "D:\python\lib\site-packages\pandas\io\excel\_base.py", line 353, in __init__
    self.book = self.load_workbook(filepath_or_buffer)
  File "D:\python\lib\site-packages\pandas\io\excel\_xlrd.py", line 37, in load_workbook
    return open_workbook(filepath_or_buffer)
  File "D:\python\lib\site-packages\xlrd\__init__.py", line 170, in open_workbook
    raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
xlrd.biffh.XLRDError: Excel xlsx file; not supported

I tried uninstall and reinstall Pandas with the pip command. The error persists. I have xlrd 2.0.1 and Pandas 1.1.5 installed.

Apr 1, 2022 in Database by Edureka
• 13,690 points
5,683 views

1 answer to this question.

0 votes

XLRDError: Excel xlsx file not supported by XLRDError: Excel xlsx file not supported by XLRDError

Out[3]: '1.1.5' In [3]: pd. version
There are a few options for resolving this issue.

Using the engine='openpyxl' option in Pandas 1.2 fixes the problem.

Use the engine='openpyxl' option.

In [4]:

df = pd.read_excel('test.xlsx',engine='openpyxl')

In [5]:

df.size
answered Apr 4, 2022 by gaurav
• 23,260 points

Related Questions In Database

0 votes
1 answer

How to read a .xlsx file using the pandas Library in iPython?

Every sheet gets its own DataFrame, which ...READ MORE

answered Mar 25, 2022 in Database by anonymous
698 views
0 votes
1 answer

How to view the XML form of an Excel file?

Excel is a spreadsheet programme. Click File->Open in ...READ MORE

answered Mar 25, 2022 in Database by Edureka
• 13,690 points
6,260 views
0 votes
1 answer

Convert .xlsb to .xlsx - Multi-sheet Microsoft Excel File

xlsb can be read by newer versions ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
5,374 views
0 votes
0 answers

Modify an existing Excel file using Openpyxl in Python

I am basically trying to copy some ...READ MORE

Mar 25, 2022 in Database by Edureka
• 13,690 points
2,084 views
0 votes
1 answer

How to create an excel file in android?

In Android, create Excel XLSX or XLS ...READ MORE

answered Apr 4, 2022 in Database by Edureka
• 13,690 points
1,278 views
0 votes
1 answer

How to open a password protected excel file using python?

I recently came upon a Python package ...READ MORE

answered Apr 6, 2022 in Database by gaurav
• 23,260 points
10,091 views
0 votes
1 answer

Unable to compress excel file (XLSX or XLS) using java

Because the formats with a 'x' at ...READ MORE

answered Apr 11, 2022 in Database by gaurav
• 23,260 points
1,435 views
0 votes
1 answer

Reading an Excel file in python using pandas

How to Use Pandas to Import an ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
2,730 views
0 votes
1 answer

How to use xlrd for writing an excel file

In Python, you can read and write ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
3,036 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP