How To Write Numpy Arrays To .txt File, Starting At A Certain Line? Numpy Version 1.6
At: How to write numpy arrays to .txt file, starting at a certain line? People helped me to solve my problem - this works for numpy Version 1.7 or later. Unfortunatelly I have to u
Solution 1:
You write your header first, then you dump the data.
Note that you'll need to add the #
in each line of the header as np.savetxt
won't do it.
time = np.array([0,60,120,180])
operation1 = np.array([12,23,68,26])
operation2 = np.array([100,123,203,301])
header='#Filexy\n#time operation1 operation2'
with open('example.txt', 'w') as f:
f.write(header)
np.savetxt(f, np.c_[time, operation1, operation2],
fmt='%d',
delimiter='\t')
Post a Comment for "How To Write Numpy Arrays To .txt File, Starting At A Certain Line? Numpy Version 1.6"