pythonxlsxxlrd

Why can't xlrd library in Python open xlsx file?


I'm trying to read .xlsx file with Python. However I noticed that popular library xlrd doesn't work with .xlsx files. Here is the example with error message I'm getting:

import xlrd

if __name__ == '__main__':
    loc = ("./excel_file.xlsx")
    wb = xlrd.open_workbook(loc)

I'm getting the following error message while trying to run the code above:

Traceback (most recent call last):
  File "/Users/username/projects/excel_processing_example/main.py", line 15, in <module>
    wb = xlrd.open_workbook(loc)
  File "/Users/username/projects/excel_processing_example/venv/lib/python3.8/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

Is there a reason why xlsx files are not supported by the xlrd library?


Solution

  • From PyPI:

    xlrd is a library for reading data and formatting information from Excel files in the historical .xls format.

    The choice was made in 2020 to just focus on the .xls format, as they didn't want to replicate the work being done by the excellent openpyxl project.