2021-07-05

用Python讀取Excel檔,已經安裝xlrd,但出現xlrd.biffh.XLRDError: Excel xlsx file; not supported錯誤訊息

 用Python讀取Excel檔,已經安裝xlrd,但出現xlrd.biffh.XLRDError: Excel xlsx file; not supported錯誤訊息,從Excel xlsx file; not supported看來,應該是xlrd不支援xls的檔案格式了...



我安裝的版本是 xlrd 2.0.1

https://pypi.org/project/xlrd/一探究竟?

  • xlrd 1.2.0 Release history: 
    Extract data from Excel spreadsheets (.xls and .xlsx, versions 2.0 onwards) on any platform. Pure Python (2.7, 3.4+). Strong support for Excel dates. Unicode-aware.
    看這個較舊的版本是有支援讀取xlsx格式的,降低版本安裝是一個解決方案。
    pip install xlrd==1.2.0
  • xlrd 2.0.0 Release history: 
    Read Excel spreadsheets from .xls files.Pure Python (2.7, 3.6+).
    啊!原來是2.0.0起,只支援.xls格式
  • xlrd 2.0.1 Project description :
    xlrd is a library for reading data and formatting information from Excel files in the historical .xls format.
    This library will no longer read anything other than .xls files. For alternatives that read newer file formats, please see http://www.python-excel.org/.
到 http://www.python-excel.org/ (Working with Excel Files in Python) 看一下囉!

可以支援python讀取xlsx的套件(package),還是有的:openpyxl, pylightxl ...

沒有留言:

張貼留言