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

相关推荐
GEOshijie12334 分钟前
GEO服务商算法适配承诺怎么验收?48小时响应的合同化考核方案
人工智能·python
卷无止境1 小时前
FastAPI 前端托管全攻略:从静态文件到大型全栈项目架构
后端·python
QQ5416451211 小时前
【驿帮查件助手python开源】开源聚合查件机器人,实现 24 类驿站批量查件取代短信通知。技术方案分享
python·机器人·开源·驿站查件机器人
卷无止境1 小时前
当FastAPI项目开始"膨胀",代码该往哪儿放
后端·python
Am-Chestnuts1 小时前
AI表格复制到Excel后日期金额和编号被改写:导入与格式检查方法
excel
用户8356290780511 小时前
Python设置PowerPoint幻灯片背景的方法
后端·python
wang_yb1 小时前
Python 中 10 个最常用的统计函数
python·databook
databook2 小时前
Python 中 10 个最常用的统计函数
python·数据分析
艾琳_lab2 小时前
Python环境配置:pip镜像设置
python
橘好き2 小时前
Python
python