title: How to save a large array in txt file in python
body: <p>I have 2D array: </p>
  
  <pre><code>import numpy as np
  
  output = np.array([1,1,6])*np.arange(6)[:,None]+1
  
  output
  Out[32]: 
  array([[ 1,  1,  1],
         [ 2,  2,  7],
         [ 3,  3, 13],
         [ 4,  4, 19],
         [ 5,  5, 25],
         [ 6,  6, 31]])
  </code></pre>
  
  <p>I tried to use   <code>np.savetxt('file1.txt', output, fmt='%10d')</code>
  i have got the result in one line only </p>
  
  <p>How can I save it in  txt file  simillar to :</p>
  
  <pre><code>        x   y    z 
          1   1    1
          2   2    7
          3   3   13
          4   4   19
          5   5   25
          6   6   31
  </code></pre>
  
  <p>3  separate columns, each column  has name (x,y,z)</p>
  
  <p><strong>Please note:</strong> the original array too large (40000000 rows and 3 columns),   I am using Python 3.6
        I have tried the solutions in <a href="https://stackoverflow.com/questions/33508633/write-a-2d-array-to-a-text-file">here</a> and <a href="https://stackoverflow.com/questions/3685265/how-to-write-a-multidimensional-array-to-a-text-file">here</a> but, it does not work with me</p>