Python Forum
working with more excel files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
working with more excel files
#1
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'
Reply


Messages In This Thread
working with more excel files - by Krszt - Mar-13-2019, 09:46 AM
RE: working with more excel files - by perfringo - Mar-13-2019, 11:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel isnt working properly after python function is started IchNar 3 212 Yesterday, 10:27 AM
Last Post: lillydalson
  Copy Paste excel files based on the first letters of the file name Viento 2 473 Feb-07-2024, 12:24 PM
Last Post: Viento
  Working with Excel and Word, Several Questions Regarding Find and Replace Brandon_Pickert 4 1,601 Feb-11-2023, 03:59 PM
Last Post: Brandon_Pickert
  How to loop through all excel files and sheets in folder jadelola 1 4,553 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  Creating csv files from Excel file azizrasul 40 5,879 Nov-03-2022, 08:33 PM
Last Post: azizrasul
  Working with excel files arsouzaesilva 6 3,226 Sep-17-2021, 06:52 PM
Last Post: arsouzaesilva
  win32com — How to resolve “AttributeError: xlUp” for Excel files? JaneTan 2 4,278 Aug-18-2021, 05:27 AM
Last Post: snippsat
Question Working with existing files Gilush 7 3,085 Feb-10-2021, 08:55 PM
Last Post: Gilush
  filecmp is not working for UTF-8 BOM encoded files sureshnagarajan 3 2,628 Feb-10-2021, 11:17 AM
Last Post: sureshnagarajan
  MP3 Tags to Excel Not working giddyhead 5 2,942 Jan-27-2021, 03:23 AM
Last Post: giddyhead

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020