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