How to write numpy arrays to .txt file, starting at a certain line? numpy version 1.6
<p>At: <a href="http://stackoverflow.com/questions/39483774/how-to-write-numpy-arrays-to-txt-file-starting-at-a-certain-line">How to write numpy arrays to .txt file, starting at a certain line?</a></p>

<p>People helped me to solve my problem - this works for numpy Version 1.7 or later. Unfortunatelly I have to use the version 1.6 - the follwoing code (thank you @Praveen)</p>

<pre><code>extra_text = 'Answer to life, the universe and everything = 42'
header = '# Filexy\n# time operation1 operation2\n' + extra_text
np.savetxt('example.txt', np.c_[time, operation1, operation2],     
               header=header, fmt='%d', delimiter='\t', comments=''
</code></pre>

<p>give me an error with numpy 1.6</p>

<pre><code>numpy.savetxt() got an unexpected keyword argument 'header' Â· Issue ...
</code></pre>

<p>Is there a work-around for Version 1.6 that produces the same result:</p>

<pre><code># Filexy
# time operation1 operation2
Answer to life, the universe and everything = 42
0   12  100
60  23  123
120 68  203
180 26  301
</code></pre>

<p>You write your header first, then you dump the data.
Note that you'll need to add the <code>#</code> in each line of the header as <code>np.savetxt</code> won't do it.</p>

<pre><code>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')
</code></pre>

python numpy