Hello,
I recently started writing a small program for reading multiple xls files from one directory.
While reading one file like this,works perfectly:

wb = xlrd.open_workbook("C:\\path\\FileName.xls")
    sh = wb.sheet_by_index(0)

this one doesn't:

os.chdir("C:\\path")
for fileName in os.listdir("."):
    wb = xlrd.open_workbook(fileName)
    sh = wb.sheet_by_index(0)

I keep getting the same error:
XLRDError: Expected BOF record; found 0x614d
I have no idea what I am doing wrong, please help.

Recommended Answers

It could be that there are files other than XLS in the folder. Try 'if files.endswith(".xls")'

Jump to Post

All 2 Replies

It could be that there are files other than XLS in the folder. Try 'if files.endswith(".xls")'

No, there were only .xls files in folder. Anyway because all the files had the same name and only numbers at the end of it were different i just did this, silly solution but it worked:

for y in numbers:
wb = xlrd.open_workbook("C:\\path\\FileName" + str(y)+ ".xls")

numbers is a list containing all numbers that appear in file names.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.