Apr-20-2019, 04:57 AM
Here is a code i wrote to find max value and its location in n number of file
I can print them in screen but dont know hoe to write them in a txt file. Could u help me
I can print them in screen but dont know hoe to write them in a txt file. Could u help me
from numpy import loadtxt from numpy import max as max2 from os import listdir, chdir, getcwd from matplotlib.pylab import where # accesing to folder with hmax_00001 ... chdir('hmax') # obtain files list file1 = listdir(getcwd()) # obtain number of files n = len(file1) # read files, one by one for i in range(n): # load file d1 = loadtxt(file1[i]) # calculate max value h1max = max2(d1) # search position of max value px, py = where(h1max==d1) # show data in screen print (file1[i],'Max = ',h1max,' loc = (',px[0],',',py[0],')') # delete variables del d1, h1max, px, py del i # return to folder initial chdir('..')