I´m trying to write a short program that will allow me to subtract values in one file (file A.dat) from other files **(B0.dat, B1.dat, B2.dat.....) I want to make a program that will repeat the process of subtracting the values A file values as many Bfiles I have(3, 7, or 81). All the files have the same amount columns. File A has one row, files B have 2rows + of co I guess the best solution would be to do a loop but I´m having errors. And at the end each corrected file I´d like to save as B0sub, B1sub, B2sub.....
file A. dat
A B C D
-1 2 2.5 4
file B0.dat
A B C D
7 8 9 10
5 3 13 11
file B1.dat
A B C D
11 12 13 14
3 4 7 8
file B2.dat
A B C D
6 8.5 5.3 1
0.8 4.2 2 9
I have totally no idea how to do it so far I tried this
import os
filepath = 'location of files'
i = 0
filename = f'B{i}.dat'
file = pd.read_csv(filepath, delimiter='\t', decimal=',', header=0)
## adding 'sub' to the file
for file in files
os.rename(os.path.join(directory,file), os.path.join, file + 'sub' + '.dat')
# next file
i += 1
filename = f'B{i}.dat'`````