title: How to copy rows from one CSV to another CSV file using Python
body: <p>I am trying to copy rows from one CSV to another, and also to remove rows after being copied from the first file. </p>
  
  <p>Please see the code, it is working for only copying specific rows from one CSV file to another, but it is not removing the rows from file 1.</p>
  
  <pre><code>import csv
  import os
  
  File1 = 'in.csv'
  File2 = 'out.csv'
  
  with open(File1, "r") as r, open(File2, "a") as w: 
       reader = csv.reader(r, lineterminator = "\n")
       writer = csv.writer(w, lineterminator = "\n")
  
       for counter,row in enumerate(reader):
           if counter&lt;0: continue
           if counter&gt;50:break
           writer.writerow(row)
  
  with open(File1, "w") as r: 
       reader = csv.writer(r, lineterminator = "\n")
  
       for counter,row in enumerate(reader):
           if counter&lt;0: continue
           if counter&gt;50:break
           reader.writerow(row)
  </code></pre>
  
  <p>Please let me know how this would work after coping the rows to the File 2 and then remove those rows from File 1.</p>
  
  <p>Here is the error:</p>
  
  <pre><code>for counter,row in enumerate(reader):
  TypeError: '_csv.writer' object is not iterable
  </code></pre>