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

相关推荐
Nina_71720 分钟前
pytorch核心组件以及流程
人工智能·pytorch·python
Highcharts.js34 分钟前
在Python中配置高度交互的数据可视化:Highcharts完全指南
开发语言·python·信息可视化·highcharts
Ace_31750887761 小时前
京东关键字搜索接口逆向:从动态签名破解到分布式请求调度
分布式·python
yachuan_qiao1 小时前
专业的建筑设备监控管理系统选哪家
大数据·运维·python
l1t2 小时前
DeepSeek辅助编写转换DuckDB json格式执行计划到PostgreSQL格式的Python程序
数据库·python·postgresql·json·执行计划
q***82912 小时前
【玩转全栈】----Django模板语法、请求与响应
数据库·python·django
李昊哲小课2 小时前
cuda12 cudnn9 tensorflow 显卡加速
人工智能·python·深度学习·机器学习·tensorflow
FreeCode2 小时前
LangChain1.0智能体开发:检索增强生成(RAG)
python·langchain·agent
xixixi777773 小时前
攻击链重构的具体实现思路和分析报告
开发语言·python·安全·工具·攻击链
Learn Beyond Limits3 小时前
Data Mining Tasks|数据挖掘任务
人工智能·python·神经网络·算法·机器学习·ai·数据挖掘