title: How to write in .csv file from a generator in python
body: <p>My Generator looks like the following:</p>
  
  <pre><code>def mygen(reader):
      for row in reader:
          yield row[0],row[1],row[2],row[3],row[4]
  </code></pre>
  
  <p>I'm trying to insert these generator produced values in the following manner:</p>
  
  <pre><code>file1=open(f2,"w")
  writes=csv.writer(file1,delimiter=' ',quoting=csv.QUOTE_ALL)
  g=mygen(reader)
  for x in g:
      writes.writerow([x])
  </code></pre>
  
  <p>It enters blank rows to the file without producing any output.
  It works perfectly when I use the same generator to insert code to a table.</p>