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

相关推荐
Blossom.11820 小时前
工业级扩散模型优化实战:从Stable Diffusion到LCM的毫秒级生成
开发语言·人工智能·python·深度学习·机器学习·stable diffusion·transformer
Lupino20 小时前
构建现代化的 Python PostgreSQL 工具库:psql_utils 的重构与优化之旅
python·postgresql
有梦想的攻城狮20 小时前
Django使用介绍
后端·python·django
沉默璇年20 小时前
PyCharm开发工具安装教程
python
大、男人21 小时前
python之Callable
开发语言·python
小二·21 小时前
Python Web 开发进阶实战:Flask 项目中的表单验证、错误处理与用户体验优化
前端·python·flask
2401_8414956421 小时前
【机器学习】人工神经网络(ANN)
人工智能·python·深度学习·神经网络·机器学习·特征学习·非线性映射
bxlj_jcj21 小时前
使用 Arthas + Heapdump + MAT 三步定位 Java 内存泄漏
java·开发语言·python
多米Domi01121 小时前
0x3f 第25天 黑马web (145-167)hot100链表
数据结构·python·算法·leetcode·链表