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)
相关推荐
kaizq20 小时前
AI-MCP-SQLite-SSE本地服务及CherryStudio便捷应用
python·sqlite·llm·sse·mcp·cherry studio·fastmcp
!chen1 天前
Error: error:0308010C:digital envelope routines::unsupporte
python
小北方城市网1 天前
分布式锁实战指南:从选型到落地,避开 90% 的坑
java·数据库·redis·分布式·python·缓存
xiaolyuh1231 天前
【XXL-JOB】 GLUE模式 底层实现原理
java·开发语言·前端·python·xxl-job
likuolei1 天前
Spring AI框架完整指南
人工智能·python·spring
二哈喇子!1 天前
PyTorch生态与昇腾平台适配:环境搭建与详细安装指南
人工智能·pytorch·python
Learner1 天前
Python数据类型(三):列表和元组
开发语言·python
世界唯一最大变量1 天前
用自创的算法快速解决拉姆奇数
python
leluckys1 天前
AI- 一种快速实现MCP服务的方法
开发语言·python
写代码的【黑咖啡】1 天前
探索 Python 中的 Vaex:高效处理大规模数据的新选择
开发语言·python