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

相关推荐
东哥很忙XH7 分钟前
python使用PyQt5开发桌面端串口通信
开发语言·驱动开发·python·qt
Dxy123931021621 分钟前
Python的正则表达式入门:从小白到能手
服务器·python·正则表达式
艾上编程28 分钟前
第三章——爬虫工具场景之Python爬虫实战:行业资讯爬取与存储,抢占信息先机
开发语言·爬虫·python
Pyeako29 分钟前
网络爬虫相关操作--selenium库(超详细版)
爬虫·python·selenium
dagouaofei32 分钟前
全面整理6款文档生成PPT工具,PDF转PPT不再难
python·pdf·powerpoint
β添砖java35 分钟前
python第一阶段第10章
开发语言·python
伊玛目的门徒1 小时前
HTTP SSE 流式响应处理:调用腾讯 智能应用开发平台ADP智能体的 API
python·网络协议·http·腾讯智能体·adp·智能应用开发平台
倔强的小石头_1 小时前
Python 从入门到实战(八):类(面向对象的 “对象模板”)
服务器·开发语言·python
qq_214782612 小时前
GWalkR,部分替代Tableau!
ide·python·jupyter
Yuner20002 小时前
Python机器学习:从零基础到深度实战
人工智能·python·机器学习