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)
相关推荐
web1508541593538 分钟前
使用Python开发经典俄罗斯方块游戏
python·游戏·pygame
缘友一世42 分钟前
PyTorch LSTM练习案例:股票成交量趋势预测
pytorch·python·lstm
olllo.top1 小时前
从 Excel 到 Data.olllo:数据分析师的提效之路
数据分析·excel
xiaohanbao091 小时前
day26 Python 自定义函数
开发语言·python·学习·机器学习·信息可视化·numpy
appleคิดถึง1 小时前
wps excel将表格输出pdf时所有列在一张纸上
pdf·excel·wps
⁤͏͏⁦⁠͏1 小时前
5月15日day26打卡
python
像风一样自由20201 小时前
算法模型部署后_python脚本API测试指南-记录3
python·算法·支持向量机
HORSE RUNNING WILD2 小时前
解决 PicGo 上传 GitHub图床及Marp中Github图片编译常见难题指南
css·python·github
ElenaYu3 小时前
mac安装cast
python·macos·cast
Dxy12393102163 小时前
python如何设置excel单元格边框样式
开发语言·python·excel