title: writing a list or array to file
body: <p>Example of the temp.txt file:</p>
  
  <blockquote>
    <p>File: t091110_065921.SFTC Src: J1903+0925 Nsub: 1 Nch: 1 Npol: 4 Nbin: 1024 RMS: 0.00118753<br>
    0 0 0 0.00148099 -0.00143755 0.000931365 -0.00296775<br>
    0 0 1 0.000647476 -0.000896698 0.000171287 0.00218597<br>
    0 0 2 0.000704697 -0.00052846 -0.000603842 -0.000868739<br>
    .<br>
    .<br>
    etc..  </p>
  </blockquote>
  
  <p>Thank you!</p>
  
  <hr>
  
  <p>In response to how this was generated, I used the following code:</p>
  
  <pre><code>for i in range(numrows):
      epoch_name = y['filename'][i]
      os.system('pdv -t {0} &gt; temp.txt '.format(epoch_name))
      stokes_line = np.genfromtxt('temp.txt', usecols=3, dtype=[('stokesI','float')], skip_header=1)
      stokes_list.append(stokes_line)
  stokes_columns = zip(*stokes_list)
  </code></pre>
  
  <p>So I am using some other software with the "pdv" command to generate a grid of values each time the programme loops (into a text file). Then I pull out 1 particular column from this text file and add it to "stokes_list". Finally I transpose the array (or whatever it is) so that the columns become rows.</p>
  
  <hr>
  
  <p>I have in Python, a list of lists (or any array, I don't understand the terminology really) that looks something like:</p>
  
  <pre><code>[((1,)(2,)(3,)),((4,)(5,)(6,)),((7,)(8,)(9,))]
  </code></pre>
  
  <p>Firstly, I'm not sure why it has parentheses inside the square brackets, as opposed to square brackets within square brackets. Secondly, I don't know why the numbers have a comma after them and themselves appear in parentheses. Anyway - perhaps more context is needed to answer this. But my real problem, is that I am trying to write this out to a file in the format:</p>
  
  <pre><code>1   2   3  
  4   5   6  
  7   8   9  
  </code></pre>
  
  <p>I am trying:</p>
  
  <pre><code>with open('final.txt','w') as f:
      for row in stokes_columns:
          f.write('\t'.join(row)+'\n')
  </code></pre>
  
  <p>Where "stokes_columns" is the name of my array / list at the top.</p>
  
  <p>I am getting the error message:</p>
  
  <pre><code>f.write('\t'.join(row)+'\n')
  TypeError: sequence item 0: expected string, numpy.void found
  </code></pre>
  
  <p>Could anyone help me with this please?</p>