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

相关推荐
烛阴9 分钟前
一文搞懂 Python 闭包:让你的代码瞬间“高级”起来!
前端·python
JosieBook19 分钟前
【Java编程动手学】Java中的数组与集合
java·开发语言·python
Gyoku Mint1 小时前
深度学习×第4卷:Pytorch实战——她第一次用张量去拟合你的轨迹
人工智能·pytorch·python·深度学习·神经网络·算法·聚类
郭庆汝7 小时前
pytorch、torchvision与python版本对应关系
人工智能·pytorch·python
Fireworkitte9 小时前
Apache POI 详解 - Java 操作 Excel/Word/PPT
java·apache·excel
思则变10 小时前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
漫谈网络10 小时前
WebSocket 在前后端的完整使用流程
javascript·python·websocket
try2find12 小时前
安装llama-cpp-python踩坑记
开发语言·python·llama
博观而约取13 小时前
Django ORM 1. 创建模型(Model)
数据库·python·django
Prodigy_kyw13 小时前
VBA初学3----实战(VBA实现Excel转csv)
excel·vba·csv