python - 使用 pandas 加载 xls 文件失败

标签 python excel pandas xlrd apache-tika

我正在尝试使用 pandas 加载 xls 文件:

pd.read_excel(fi_name, sheet_name=None, engine=None)
但我得到这个错误:
"XLRDError: Workbook is encrypted"
但是文件没有加密,我可以用 excel 打开它,然后用 tika 包读取文件的文本。
有人知道我该如何解决吗?
此外,有谁知道用于读取所有 excel 文件格式的 python 包,
即使 Pandas 失败了?
谢谢

最佳答案

我想,我为你的问题找到了一些东西:

import msoffcrypto

file = msoffcrypto.OfficeFile (open ('encrypted.xls', 'rb')) # read the original file
file.load_key (password = 'VelvetSweatshop') # Fill in the password, if it can be opened directly, the default password is 'VelvetSweatshop'
file.decrypt (open ('decrypted.xls', 'wb')) # Save it as a new file after decryption
之后就可以使用xlrd正常打开和操作解密后的文件了。
你可以安装包
pip install msoffcrypto
你可以看到完整的文档 here

关于python - 使用 pandas 加载 xls 文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68256650/

相关文章:

VBA,Excel 宏 : copy cell value to another sheet, 偏移量,重复直到找到空单元格

Excel 自动化在 C++Builder XE7 中不起作用

python - pandas 数据框按组和日期计算重复项

python - 两人骰子游戏的得分问题

xml - Excel with xml -> 标记和属性的来源和指南

java - Spark 错误 - 不支持的类文件主要版本

python Pandas : How to get multiple subsets of dataframe efficiently based on id column

python - 如何对 pandas 中的每个组进行前向填充

python - 从 Python 脚本使用 POST 发送文件

python - 我应该如何将我的 s3 凭证传递给 AWS 上的 Python lambda 函数?