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

相关推荐
爱睡懒觉的焦糖玛奇朵20 小时前
【从视频到数据集:焦糖玛奇朵的魔法工具使用说明】
人工智能·python·深度学习·学习·算法·yolo·音视频
yangshicong21 小时前
第11章:结构化输出与数据提取 —— 让 AI 直接返回你想要的数据格式
数据库·人工智能·redis·python·langchain·ai编程
言之。21 小时前
【Python】免费的中文 AI 配音方案
开发语言·人工智能·python
Warson_L21 小时前
python dict key详解
python
天天进步20151 天前
Python全栈项目:从零手操一个高性能 API 网关
开发语言·python
安生生申1 天前
使用pygame实现2048
开发语言·python·pygame
徐图图不糊涂1 天前
搭建简易版的Rag系统
python·pycharm
SunnyDays10111 天前
Java 读写 Excel 公式:从基础到高级的实战总结
java·开发语言·excel
灰灰勇闯IT1 天前
pyasc:用 Python 调用 CANN 的推理能力
开发语言·python
明月_清风1 天前
FastAPI 从入门到实战:3 分钟构建高性能异步 API
后端·python·fastapi