title: How to write a numpy array to a csv file?
body: <p>I want to open up a new text file and then save the numpy array to the file. I wrote this bit of code:</p>
  
  <pre><code>foo = np.array([1,2,3])
  abc = open('file'+'_2', 'w')
  np.savetxt(abc, foo, delimiter=",")
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-33-fea41927952b&gt; in &lt;module&gt;()
        2 model = cool
        3 abc = open('file'+'_2', 'w')
  ----&gt; 4 np.savetxt(abc, foo, delimiter=",")
  
  /usr/local/lib/python3.4/site-packages/numpy/lib/npyio.py in savetxt(fname, X, fmt,     delimiter, newline, header, footer, comments)
     1071         else:
     1072             for row in X:
  -&gt; 1073                 fh.write(asbytes(format % tuple(row) + newline))
     1074         if len(footer) &gt; 0:
     1075             footer = footer.replace('\n', '\n' + comments)
  
  TypeError: must be str, not bytes
  </code></pre>
  
  <p>Does anyone know whats wrong?</p>
  
  <p>Additionally, I found an empty file created in the terminal called file_2, but nothing is written inside it.</p>
  
  <p>EDIT: I am using Python3.4</p>