Search code examples
pythonxlrd

xlrd python library


import xlrd
wb = xlrd.open_workbook("file.xls")

wb.sheet_names()

sh = wb.sheet_by_index(0)

for item in sh.col(0):
    value = unicode(item.value)
    if value.startswith("cheap"):
        print value

when i trying this code, interpritator return me: AttributeError: 'module' object has no attribute 'open_workbook' whats wrong? in all manuals typeed this code!


Solution

  • The most likely explanation is that you've accidentally created your own xlrd.py file that is being found before the real one.

    The solution is to find the imposter and delete it. Try import xlrd; print xlrd.__file__ to find the culprit :-)

    P.S. You will need to delete both the .py file and its .pyc cached version.