I have folders containing a specific file len_J.py
. I am reading every folder and calculating average for each line. But this code doesn't work when one of the folders doesn't have len_J.py
. Basically, it should calculate average of folders which have len_J.py
in them and skip the ones which don't.
NFILES = 3
values = [[] for _ in range(NFILES)]
for i in range(NFILES):
with open(rf"C:\Users\USER\OneDrive - Technion\Research_Technion\Python_PNM\Surfactant A-D\Trials\{i+1}\len_J.py") as data:
values[i] += map(int,filter(lambda x: x.strip().isdecimal(), data))
for t in zip(*values):
print(sum(t)//len(t))