我正在尝试使用 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/