-2

So I am trying to search through multiple excel files using openpyxl. I've seen ways to do it where you have 3 maybe 4 files, however I am looking to do it with roughly 30 files. The list of files grows daily so I was wondering if there is a command to just use all files in a folder or something of that nature. Luckily each workbook only has one sheet per book

I don't have much as this is one of my first times using python in a long time however what I do have is below

>>> import openpyxl
>>> wb = openpyxl.load_workbook('example.xlsx')
>>> type(wb)
<class 'openpyxl.workbook.workbook.Workbook'>
Shane
  • 72
  • 1
  • 13
  • what is the problem? what does not work currently?? – Drako Jun 10 '19 at 13:29
  • It's not that its not working its that I need help doing what I described above the code as I do not completely understand it – Shane Jun 10 '19 at 15:15

1 Answers1

2

You can try glob glob and loop through each file.

import glob
for filename in glob.glob('Folder/*.xlsx'):
    print (filename) # instead of print you can use load_workbook.

You can take a look at this link :

How to open every file in a folder?

Sam
  • 1,206
  • 2
  • 12
  • 27