title: Inserting column name headers into a Python list
body: <p>I am trying to insert column headers into a Python list. The csv file I am using does not have column names and the data is separated by commas. I am trying to write this program so that I don't have to insert column names into the csv file every time I make the weekly maps in ArcGIS. I could also turn the csv into a dictionary if needed. Either way would be fine. I have this code so far which produces a dataset that is useable. I know how to reference columns in a dictionary by column name. But the same method doesn't seem to work for inserting column names into a column position.</p>
  
  <pre><code>import os
  os.chdir('C:\Users\####\Desktop')
  fileData = open('SOUTH_06_01_2015_SECFILE.CSV','rb')
  
  def dataHeader():
      headerLine = fileData.readline()
      valueList = headerLine.split(',')
      yield valueList
  
  def dataBody():
      for line in fileData.readlines():
          segmentLine = line.split(',')
          yield segmentLine[0:6]
  
  def dataPrinter():
      gen1 = dataHeader()
      gen2 = dataBody()
      print'\n'
      for row in gen2:
          print row
  dataPrinter()
  </code></pre>