title: How to add a new column to a CSV file?
body: <p>I have several <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="noreferrer">CSV</a> files that look like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>Input
  Name        Code
  blackberry  1
  wineberry   2
  rasberry    1
  blueberry   1
  mulberry    2
  </code></pre>
  
  <p>I would like to add a new column to all CSV files so that it would look like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>Output
  Name        Code    Berry
  blackberry  1   blackberry
  wineberry   2   wineberry
  rasberry    1   rasberry
  blueberry   1   blueberry
  mulberry    2   mulberry
  </code></pre>
  
  <p>The script I have so far is this:</p>
  
  <pre><code>import csv
  with open(input.csv,'r') as csvinput:
      with open(output.csv, 'w') as csvoutput:
          writer = csv.writer(csvoutput)
          for row in csv.reader(csvinput):
              writer.writerow(row+['Berry'])
  </code></pre>
  
  <p>(Python 3.2)</p>
  
  <p>But in the output, the script skips every line and the new column has only Berry in it:</p>
  
  <pre class="lang-none prettyprint-override"><code>Output
  Name        Code    Berry
  blackberry  1   Berry
  
  wineberry   2   Berry
  
  rasberry    1   Berry
  
  blueberry   1   Berry
  
  mulberry    2   Berry
  </code></pre>