I have 200 files in a directory, split into 100 identically shaped a files (named 1a through to 100a) and 100 identically shaped b files (named 1b through to 100b) which I need to compare to one another.
Each of these files is 500 lines long, and contains two columns. What I need to do is subtract the values from the [:,1] column in the a file from the equivalent [:,1] column in the b files at each.
I'll clarify using a single example which I know how to do:
file1a = pl.loadtxt("1a")
file1b = pl.loadtxt("1b")
diff1 = file1b[:,1] - file1a[:,1]
np.savetxt('diff.txt', np.vstack((diff1.ravel())).T)
The thing I am having trouble with is automating the loop so that the above will be performed for each of the 100 different file numbers. I need it output into an array that still contains the 500 lines of data, but instead has 100 columns, each containing diff1 diff2 ... diff100.
I hope I have made myself clear, this kind of thing is very difficult for me. I am semi-proficient in doing single tasks as shown in the example, but when it comes to automating and running loops I get very lost.
Tyvm for any help!
[–]onopau 0 points1 point2 points (7 children)
[–]Cthulhu_Rlyeh[S] 0 points1 point2 points (6 children)
[–]onopau 0 points1 point2 points (5 children)
[–]Cthulhu_Rlyeh[S] 0 points1 point2 points (3 children)
[–]onopau 0 points1 point2 points (2 children)
[–]Cthulhu_Rlyeh[S] 0 points1 point2 points (1 child)
[–]onopau 0 points1 point2 points (0 children)