pythonpython-3.xexcelxlrd

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


Hello I'm trying to read an excel file 'myFile.xlsx' using datatable.fread (version 1.0.0) function to speedup data manipulation.

The problem is I had an AttributeError: module 'xlrd' has no attribute 'xlsx'.

The command I used is:

import datatable as dt
DT = dt.fread("myFile.xlsx")

I checked the module where the error occurred is the module xls of datatable package:

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

Is there any solution to fix this issue? please.


Solution

  • The issue is that datatable package is not updated yet to make use of xlrd>1.2.0, so in order to make it work you have to install xlrd = 1.2.0

    pip install xlrd==1.2.0
    

    I hope it helped.