![]() |
working with more excel files - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: working with more excel files (/thread-16749.html) |
working with more excel files - Krszt - Mar-13-2019 Hello, I would like to modify my existing code that extracts the value of some cells. How can I modify it to do it not only one but for more xls, that are in the same directory. I tried something like this: import xlrd import glob for filename in glob.glob('*.xls'): book = xlrd.open_workbook("*.xls", formatting_info=True) sheets = book.sheet_names() for index, sh in enumerate(sheets): sheet = book.sheet_by_index(index) #print "Sheet:", sheet.name rows, cols = sheet.nrows, sheet.ncols #print "Number of rows: %s Number of cols: %s" % (rows, cols) for row in range(rows): for col in range(cols): ....the error is Quote:IOError: [Errno 22] invalid mode ('rb') or filename: '*.xls' RE: working with more excel files - perfringo - Mar-13-2019 Shouldn't on row #5 be filename, not "*.xls"? |