title: Reading column names alone in a csv file
body: <p>I have a csv file with the following columns:</p>
  <p>id,name,age,sex</p>
  <p>Followed by a lot of values for the above columns.
  I am trying to read the column names alone and put them inside a list.</p>
  <p>I am using Dictreader and this gives out the correct details:</p>
  <pre><code>with open('details.csv') as csvfile:
      i=[&quot;name&quot;,&quot;age&quot;,&quot;sex&quot;]
      re=csv.DictReader(csvfile)
      for row in re:
          for x in i:
              print row[x]
  </code></pre>
  <p>But what I want to do is, I need the list of columns, (&quot;i&quot; in the above case)to be automatically parsed with the input csv than hardcoding them inside a list.</p>
  <pre><code>with open('details.csv') as csvfile:
     
      rows=iter(csv.reader(csvfile)).next()
      header=rows[1:]
      re=csv.DictReader(csvfile)
      for row in re:
          print row
          for x in header:
              
              print row[x]
  </code></pre>
  <p>This gives out an error</p>
  <pre><code>Keyerrror:'name'
  </code></pre>
  <p>in the line print row[x]. Where am I going wrong? Is it possible to fetch the column names using Dictreader?</p>