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)
相关推荐
子不语1801 小时前
Python——函数
开发语言·python
daidaidaiyu1 小时前
一文入门 LangChain 开发
python·ai
JJ1M82 小时前
用 Python 快速搭建一个支持 HTTPS、CORS 和断点续传的文件服务器
服务器·python·https
汤姆yu3 小时前
基于python大数据的小说数据可视化及预测系统
大数据·python·信息可视化
x***J3483 小时前
Python多线程爬虫
开发语言·爬虫·python
m***D2863 小时前
Python网络爬虫实战案例
开发语言·爬虫·python
ID_180079054733 小时前
基于 Python 的淘宝商品详情数据结构化解析:SKU、价格与库存字段提取
开发语言·数据结构·python
Laughtin4 小时前
终端Python环境的选择与切换
开发语言·python
JHC0000004 小时前
Python PDF 相关操作
开发语言·python·pdf
databook4 小时前
Manim进阶:用背景图片让你的数学视频脱颖而出
python·动效