'np.gentext loop and fill empty array in python
I have 50 different folders (from 0 to 50) with the data I want to plot named as data_A, data_B, data_C, data_D. How do I iterate through the 50 folders, collect the data, apply a numerical operation and print the output (V) to a list? The final goal would be to make a boxplot of (V) for each folder.
Hope that this attempt of code helps in understanding my aim:
directory='/path_to_data/'
folders = [0..50]
for i in (len(folders)):
A = (np.genfromtxt(directory/[i]/'data_A.dat')
B = (np.genfromtxt(directory/[i]/'data_B.dat')
C = (np.genfromtxt(directory/[i]/'data_C.dat')
D = (np.genfromtxt(directory/[i]/'data_D.dat')
V = (A+B+C+D)/4 #make and average of the data
DATA=[V,..]
NAMES=[folder$i,.. ]
done
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
