How can I save data to a file (that I will plot later on) effectively?
I have got this from my research:
#Open new data file
f = open("data2.txt", "w")
f.write( str(yEst) ) # str() converts to string
f.close()
Here is a bit of my code so far:
for i in drange2(0, 2*math.pi + 0.0634665182543392 , 0.0634665182543392):
for x in range(1,N+1):
yEst = yEst + a * cos(x* i)
#print yEst
f.write( str(yEst) ) # str() converts to string
yEst=0
f.close()
Now, when I go and open my file "data2.txt
" I can not read the data because it is not 'organized'. How can I go to the next line using the f.write( str(yEst) )
so that I have a column that contains my 'yEst' data into the file "data2.txt?
Thank you in advance for your consideration :)
PS: yEst looks like (in the data2.txt file): 48.901347147148.605785828748.114506165947.429486 ..
and I want it as a column: -->
48.9013471471 (new line)
48.6057858287 (new line)
48.1145061659 (new line)
47.4294863684
etc ..