python - Two text files with 1,096 individual decimal numbers - subtract each of the elements and total the sum -
i have 2 text files contain 1,096 values (these features extracted neural network layer).
i want take first element of the first text file , subtract first element of second text file , on through 1,096 decimal values.
i want take sum of these subtractions , store in variable later use.
i new python i'm unsure best way access each element - aiming method similar euclidean distance method.
assuming files 1.txt
, 2.txt
import decimal dc open('1.txt','rb') fin1, open('2.txt','rb') fin2: sub_sum = 0 x,y in zip(fin1,fin2): sub_sum += dc.decimal(x) - dc.decimal(y)
Comments
Post a Comment