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

I can't read excel file using dt.fread from datatable AttributeError

您好,我正在尝试使用 datatable.fread(版本 1.0.0)函数读取 excel 文件 'myFile.xlsx' 以加速数据操作。

问题是我有一个 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

希望对您有所帮助。