0221 解决万得导出数据excel无法python读入的问题

报错如下: TypeError: <class 'openpyxl.styles.named_styles._NamedCellStyle'>.name should be <class 'str'> but value is <class 'NoneType'>

原因分析:

万得导出的xlsx带有某些格式,比如首行加粗,excel桌面端工具能打开,但openpyxl报错,导致无法批量处理 ,

修改方法:

使用python3.8 安装旧版pandas和xlrd,并在pandas代码中指定引擎使用xlrd

\Python38\Scripts\pip.exe install pandas==1.3.5 -i https://pypi.tuna.tsinghua.edu.cn/simple

\Python38\Scripts\pip.exe install xlrd=1.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

pd .read_excel (pdf_path, usecols=None, engine='xlrd')

提供解决思路的原文地址:

agileminorcommented on Apr 29, 2022

I found a different work around - in pandas 1.3.5 (or earlier) and xlrd version < 2.0, use engine='xlrd' and the ViCell file can be opened successfully.

来自 <BUG: pandas cannot open xlsx with openpyxl engine · Issue #40499 · pandas-dev/pandas · GitHub>

最后使用python38就可以使用了。

C:\Users\charlie\AppData\Local\Programs\Python\Python38\python.exe mergeTables.py

相关推荐
copyer_xyf28 分钟前
LangChain 调用 LLM
后端·python·agent
copyer_xyf37 分钟前
Prompt 组织管理
后端·python·agent
shimly1234561 小时前
python3 uvicorn 是啥?
python
CTA量化套保2 小时前
期货量化程序 time.sleep 卡死:天勤单线程与 deadline 替代
python·区块链
GIS数据转换器2 小时前
城市排水生命线安全运行监测平台深度解析
java·运维·人工智能·python·安全·数据挖掘·无人机
贤哥哥yyds3 小时前
GBK转UTF\-8编码自动转换工具 使用文档
python
数量技术宅3 小时前
2026量化前沿:从Reddit热帖到Python实战,如何用赫斯特指数(Hurst)狙击虚假突破?
开发语言·python
华如锦3 小时前
面了很多 Java转AI Agent方向,一些面试题总结
java·开发语言·人工智能·python·ai
戴西软件3 小时前
戴西 DLM 许可授权管理系统:破解无网络环境下工业软件授权难题,助力制造企业降本增效
网络·人工智能·python·深度学习·程序人生·算法·制造
Dxy12393102164 小时前
Python线程锁:为什么多线程会“打架“,以及怎么解决
开发语言·前端·python