I have been looking at lots of examples online of what I'm trying to do without a clear path forward. I need to use a wildcard to open a file with the same ending as in *era5.wind that are located in a large directory of folders (~400). I need to open each folder, read the *era5.wind file, make some calculations, save each calcuation in a variable with the folder name, close the folder and file and do the same until the end of the folder list. My folders look like this:
What is the best pythonic way to read each folder from beginning to end and repeating the process for each file? Thank you for your help!
I think os.walk
is what you're looking for here.