I want to match the values of a specific column of a txt file named A with 10 other txt files named (A_1,A_2......A_10) and find the sum of square of differences for each txt files. So, basically, i want Python to print out the 3 smallest differences and their corresponding txt files (A_1,A_2,.....A_10). I have been able to find the differences but stuck at how to find the 3 smallest differences and their corresponding txt files.
import numpy as np
filelist=[]
for i in range(1,11):
filelist.append("/Users/Hrihaan/Desktop/A_%s.txt" %i)
for fname in filelist:
data=np.loadtxt(fname)
data1=np.loadtxt('/Users/Hrihaan/Desktop/A.txt')
x=data[:,1]
x1=data1[:,1]
x2=(x-x1)**2
x3=sum(x2)
print(fname)
print(x3)