在使用pandas读取xlsx文件时,报错:Excel xlsx file; not supported
import pandas as pd
df = pd.read_excel('../datas/1.xlsx')
报错:
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
XLRDError Traceback (most recent call last)
in
······
865 self._io = stringify_path(path_or_buffer)
866
--> 867 self._reader = self._engines[engine](self._io)
868
869 def __fspath__(self):
...
39 @property
d:\develop\learning\installed\Python36\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)
XLRDError: Excel xlsx file; not supported
解决:
- 安装xlrd时指定版本
pip install xlrd==1.2.0
| 但是这个我使用后未能解决,g! |
- 指定engine
安装openpyxl
pip install openpyxl
df = df = pd.read_excel('../datas/1.xlsx', engine="openpyxl")
.
姓名 年龄 性别 身高
0 田 18 男 170
1 王 16 男 175
2 王二 17 男 181
3 卢一 15 男 185
4 王三 16 女 158
5 卡特 18 女 170
| ok了。 |
在尝试使用Pandas的read_excel函数读取xlsx文件时遇到了Excelxlsxfile;notsupported错误。首先尝试通过安装xlrd特定版本(1.2.0)来解决,但该方法无效。然后,通过指定引擎参数engine为openpyxl,成功地用openpyxl库读取了xlsx文件。
4万+

被折叠的 条评论
为什么被折叠?



