Open excel file in Python: XLRDError: Excel xlsx file; not supported

2020
May 05, 2021, at 12:10 PM

I want to open an Excel file in Python, using:

import xlrd
loc = (r"C:\Users\my_path\my_file.xlsx")
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)

and it caught error:

---------------------------------------------------------------------------
XLRDError                                 Traceback (most recent call last)
<ipython-input-70-b399ced4986e> in <module>
      4 loc = (r"C:\Users\my_path\my_file.xlsx")
      5 
----> 6 wb = xlrd.open_workbook(loc)
      7 sheet = wb.sheet_by_index(0)
      8 sheet.cell_value(0, 0)
C:\Python38\lib\site-packages\xlrd\__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows, ignore_workbook_corruption)
    168     # files that xlrd can parse don't start with the expected signature.
    169     if file_format and file_format != 'xls':
--> 170         raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
    171 
    172     bk = open_workbook_xls(
XLRDError: Excel xlsx file; not supported

What is wrong?

Answer 1

The lastest version of xlrd is only support .xls file, so you can install the older version

pip uninstall xlrd
pip install xlrd==1.2.0
Rent Charter Buses Company
READ ALSO
Restrictions on non-SDK interfaces with androidx.appcompat library

Restrictions on non-SDK interfaces with androidx.appcompat library

Due to Restrictions on non-SDK interfaces on app targeting Android 11, I have used vertex tool provided by Android Developers site to find list of non-SDK API in my app

139
TypeError: event.preventDefault is not a function

TypeError: event.preventDefault is not a function

I am following a tutorial and copied everything but got this error "TypeError: eventpreventDefault is not a function" in the onSubmit() but the event

256
Which CSS properties affect the accesibility tree?

Which CSS properties affect the accesibility tree?

By the sacred separation of contents and presentation, I assumed that CSS was ignored by screen readersThis naive assumption is false

108
ReferenceError: require is not defined on github action

ReferenceError: require is not defined on github action

I run the npm run build on github action but it shows the error of ReferenceError: require is not defined

188