I have a bunch of folders, each containing a set and equal number of files. I want to use python to loop through each folder and do some analysis to each file. I want to store the results of the analysis within a numpy array.
For example, suppose we have 3 folders, each containing 5 files. I want the analysis results to be stored within an array results=np.zeros((3,5))
Here's a code snippet close to what I want, but not correct.
results=np.zeros((3,5))
dircount=0
filecount=0
for root, dirs, files in os.walk(ROOTFOLDER):
for dir in root:
for file in dirs:
result[dircount,filecount]=#do some analysis with file
filecount=filecount+1
dircount=dircount+1
filecount=0
print result
I must confess, I do not fully understand how os.walk works, but it seems good for jobs involving a loop through files and folders.