title: How to write header row with csv.DictWriter?
body: <p>Assume I have a <code>csv.DictReader</code> object and I want to write it out as a CSV file. How can I do this?</p>
  
  <p>I know that I can write the <strong>rows of data</strong> like this:</p>
  
  <pre><code>dr = csv.DictReader(open(f), delimiter='\t')
  # process my dr object
  # ...
  # write out object
  output = csv.DictWriter(open(f2, 'w'), delimiter='\t')
  for item in dr:
      output.writerow(item)
  </code></pre>
  
  <p>But how can I include the fieldnames?</p>