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

相关推荐
吴佳浩2 小时前
GPU 编号进阶:CUDA\_VISIBLE\_DEVICES、多进程与容器化陷阱
人工智能·pytorch·python
全栈凯哥3 小时前
18.Python中的导入类完全指南
python
sunwenjian8863 小时前
Java进阶——IO 流
java·开发语言·python
guts3504 小时前
图像篡改数据集下载:COVERAGE、CASIA
python·数据集
森林猿4 小时前
java-modbus-读取-modbus4j
java·网络·python
2401_879693874 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python
chushiyunen4 小时前
python chatTts实现tts文本转语音、音频
python
FreakStudio5 小时前
把 Flask 搬进 ESP32,高中生自研嵌入式 Web 框架 MicroFlask !
python·单片机·嵌入式·cortex-m3·异步编程·电子diy
love530love5 小时前
OpenClaw 手机直连配置全流程
人工智能·windows·python·智能手机·c#·agent·openclaw
chushiyunen6 小时前
python中的内置属性 todo
开发语言·javascript·python