python - Difference between a range of values of txt files -


so have 10 txt files named a_1,a_2,......a_10 , working txt file named a. in each column of these txt files, there 4320 values. goal compare first 1440 values of column of txt file other 10 txt files(a_1,a_2,.....a_10) , find sum of square of differences. approach gives me difference of 4320 values, stuck @ how manipluate code find difference of first 1440 values:

import numpy np filelist=[] in range(1,11):     filelist.append("/users/hrihaan/desktop/a_%s.txt" %i) 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) 

adding slice below should trick.

np.loadtxt(fname)[:1440] 

it causes data include rows indexed 0 not including 1440... since python zero-based indexing, gives 1440 rows total.

for fname in filelist:     data=np.loadtxt(fname)[:1440]     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) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -