I have 10 txt files named A_1,A_2.......A_10 and I want to compare it with a txt file named A. My goal is to find the sum of differences between values of a specific column,but the problem is both in the 10 txt files(A_1,A_2.....A_10) and in A,i have some bad values in a column which are equal to -1.00000E+31.I am stuck at how to manipulate the code so that Python skips whenever the value is equal to -1.00000E+31 and moves onto the next one, thought of using np.nan but that's not working as it's giving the total sum to be equal to nan. Any suggestion would be really helpful.
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]
bad = np.where(data[:,1] == -1E31)
data[bad,1] = np.nan
bad1 = np.where(data1[:,1] == -1E31)
data1[bad1,1] = np.nan
x2=(x-x1)
x3=sum(x2)
print(fname)
print(x3)