pandas读excel类型文件报错: xlrd.biffh.XLRDError: Excel xlsx file; not supported

简介: pandas读excel类型文件报错: xlrd.biffh.XLRDError: Excel xlsx file; not supported

pandas读excel类型文件报错: xlrd.biffh.XLRDError: Excel xlsx file; not supported


一、问题

pandas 读取 Excel 文件(.xlsx)时报错如下:

raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')

xlrd.biffh.XLRDError: Excel xlsx file; not supported

二、报错原因

xlrd 版本过低,只支持读取 .xls 文件

三、解决方案

1、方法一

先卸载低版本的 xlrd,然后安装新版本:

pip uninstall xlrd
pip install xlrd==1.2.0

或者使用 conda 卸载和安装:

conda uninstall xlrd
 conda install xlrd=1.2.0

2、方法二

用 openpyxl 代替 xlrd 打开 .xlsx 文件:

df = pandas.read_excel(‘data.xlsx’,engine='openpyxl')

相关文章
|
存储 数据挖掘 数据处理
pandas 读取xlsx文件复制文件
Pandas 提供了强大的功能来读取和处理 Excel 文件,通过结合使用 `read_excel` 和 `to_excel` 方法,可以轻松地对 Excel 文件进行读取、处理和复制。无论是处理单个工作表还是多个工作表,Pandas 都能高效地完成任务。
369 11
|
数据挖掘 Python
【Python】已解决:Python pandas读取Excel表格某些数值字段结果为NaN问题
【Python】已解决:Python pandas读取Excel表格某些数值字段结果为NaN问题
1668 0
|
数据可视化 数据处理 Python
使用Pandas实现Excel中的数据透视表功能
本文介绍了如何使用Python的Pandas库实现Excel中的数据透视表功能,包括环境准备、创建模拟销售数据、代码实现及输出等步骤。通过具体示例展示了按地区和销售员汇总销售额的不同方法,如求和、平均值、最大值等,帮助读者掌握Pandas在数据处理上的强大能力。
536 12
|
Python
pandas 生成 Excel 时的 sheet 问题
pandas 生成 Excel 时的 sheet 问题
450 1
|
数据采集 索引 Python
pandas处理excel
pandas处理excel
|
Python
【Python】解决pandas读取excel,以0向前填充的数字会变成纯数字
本文介绍了两种解决Python使用pandas库读取Excel时,数字前填充的0丢失问题的方法:一是在读取时指定列以字符串格式读取,二是在Excel中预先将数值转换为文本格式。
1178 0
【Python】解决pandas读取excel,以0向前填充的数字会变成纯数字
|
Python
Python:Pandas实现批量删除Excel中的sheet
Python:Pandas实现批量删除Excel中的sheet
611 0
|
算法 数据挖掘 Java
日常工作中,Python+Pandas是否能代替Excel+VBA?
日常工作中,Python+Pandas是否能代替Excel+VBA?
238 0
|
Python
Pandas 读取 Excel 斜着读
Pandas 读取 Excel 斜着读
140 0
|
Python
[pandas]从多个文件中构建dataframe
[pandas]从多个文件中构建dataframe
159 0