Pandas读取excel异常

python 复制代码
Pandas 处理excel异常: ValueError: Excel file format cannot be determined, you must specify an engine manually.

今天使用pandas 处理excel的时候,抛出异常:ValueError: Excel file format cannot be determined, you must specify an engine manually. 异常的内容是:无法确定Excel文件格式,需要手动指定引擎, 运行结果看下图

python 复制代码
df_all = pd.read_excel("./result.xls")
print(df_all.columns)

因为我在使用pandas的时候没有写engine的习惯,所以我就直接加上 engine='openpyxl' 运行结果见下图

python 复制代码
df_all = pd.read_excel('./result.xls', engine='openpyxl')
print(df_all.columns)

运行后继续抛出异常 zipfile.BadZipFile: File is not a zip file 意思就是 zipfile.BadZipFil: File不是zip文件, 这里我能想到的就是xls的文件格式应该是有问题,我打开xls文件然后另存为xlsx文件后 就可以正常运行了, 运行结果见下图

python 复制代码
df_all = pd.read_excel("./result.xlsx")
print(df_all.columns)
相关推荐
酷爱码3 分钟前
Python虚拟环境与Conda的使用方式详解
开发语言·python·算法
大模型真好玩11 分钟前
GRPO 代码实战!让大模型具备思维能力,打造你的专属DeepSeek
人工智能·python·deepseek
码海漫游者814 分钟前
让Python成为你的网站引擎:Django全栈开发初体验!!!
数据库·python·其他·django
秋山落叶万岭花开ღ25 分钟前
树的基本概念与操作:构建数据结构的层级世界
数据结构·python·算法
山花1 小时前
什么是“Pythonic”?——写出更优雅的Python代码(上)
后端·python
Dfreedom.1 小时前
Excel文件数据的读取和处理方法——C++
c++·数据分析·excel·数据预处理
Humbunklung2 小时前
全连接层和卷积层
人工智能·python·深度学习·神经网络·机器学习·cnn
站大爷IP2 小时前
使用Python时要注意的十大陷阱
python
Keya2 小时前
使用 tinypng 脚本打包为exe 进行压缩图片
前端·python·程序员
Tom Boom2 小时前
Pytest断言全解析:掌握测试验证的核心艺术
自动化测试·python·测试开发·pytest