python - 我无法使用数据表 AttributeError 中的 dt.fread 读取 excel 文件

标签 python python-3.x excel xlrd

您好,我正在尝试使用 datatable.fread 读取 excel 文件 'myFile.xlsx' (版本 1.0.0)函数来加速数据操作。
问题是我有一个 AttributeError: module 'xlrd' has no attribute 'xlsx'.我使用的命令是:

import datatable as dt
DT = dt.fread("myFile.xlsx")
我检查了发生错误的模块是datatable的模块xls包裹:
def read_xls_workbook(filename, subpath):
    try:
        import xlrd
        # Fixes the warning
        # "PendingDeprecationWarning: This method will be removed in future
        #  versions.  Use 'tree.iter()' or 'list(tree.iter())' instead."
        xlrd.xlsx.ensure_elementtree_imported(False, None) # Here
        xlrd.xlsx.Element_has_iter = True # and Here
有什么解决方案可以解决这个问题吗?请。

最佳答案

问题是数据表包尚未更新以使用 xldr>1.2.0,因此为了使其工作,您必须安装 xldr = 1.2.0

pip install xldr==1.2.0
我希望它有所帮助。

关于python - 我无法使用数据表 AttributeError 中的 dt.fread 读取 excel 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70035997/

相关文章:

excel - 代码执行被中断

python - 在数据帧上使用 python 进行快速文本处理

python - 属性错误: 'Worker' object has no attribute 'idf'

excel - 从开始日期和结束日期填写单元格

python-3.x - Pandas 时间序列的百分比变化

python - 使用类名、css-选择器和 xpath 从网站中查找元素

.net - 发布 Tlb 新版本以及何时需要重新引用 Tlb

python - 将度数转化为三电机运动

python - 函数范围与方法

python - 将我的 docker 连接到外部 docker