How to write numpy arrays to .txt file, starting at a certain line?
<p>I need to write 3 numpy arrays into a txt file. The head of the file looks like that:</p>

<pre><code>#Filexy
#time  operation1 operation2
</code></pre>

<p>The numpy arrays look like the following:</p>

<pre><code>time = np.array([0,60,120,180,...])
operation1 = np.array([12,23,68,26,...)]
operation2 = np.array([100,123,203,301,...)]
</code></pre>

<p>In the end, the .txt file should look like this (delimiter should be a tab):</p>

<pre><code>#Filexy
#time  operation1 operation2
0   12   100
60  23    123
120  68   203
180  26   301
..  ...   ...
</code></pre>

<p>I tried it with "numpy.savetxt" - but I did not get the format that I want.</p>

<p>Thank you very much for your help!</p>

<p>Try this:</p>

<pre><code>f = open(name_of_the_file, "a")
np.savetxt(f, data, newline='\n')
f.close()
</code></pre>

python numpy writetofile