title: Arranging columns python
body: <p>I'm really stuck on some code. Been working on it for a while now, so any guidance is appreciated. I'm trying to map many files related columns into one final column. The logic of my code will start by</p>
  
  <ol>
  <li>identifying my desired final column names</li>
  <li>reading the incoming file</li>
  <li>identifying the top rows as my column headers/names</li>
  <li>identifying all underneath rows as data for that column</li>
  <li>based on the column header, add data from that column to the most closely related column, and</li>
  <li>have an exit condition (if no more data, end program).</li>
  </ol>
  
  <p>If anyone could help me with steps 3 and 4, I would greatly appreciate it because that is where I'm currently stuck.</p>
  
  <p>It says I have a <code>KeyError:0</code> where it says <code>columnHeader=row[i]</code>. Does anyone know how to solve this particular problem?</p>
  
  <pre><code>#!/usr/bin/env python
  import sys #used for passing in the argument
  import csv, glob
  
  SLSDictionary={}
  
  fieldMap = {'zipcode':['Zip5', 'zip4'],
          'firstname':[],
          'lastname':[],
          'cust_no':[],
          'user_name':[],
          'status':[],
          'cancel_date':[],
          'reject_date':[],
          'streetaddr':['address2', 'servaddr'],
          'city':[],
          'state':[],
          'phone_home':['phone_work'],
          'email':[]
          }
  
  CSVreader = csv.DictReader(open( 'N:/Individual Files/Jerry/2013 customer list qc, cr, db, gb 9-19-2013_JerrysMessingWithVersion.csv', "rb"),dialect='excel', delimiter=',')
  
  i=0
  for row in CSVreader:
          if i==0:
              columnHeader = row[i]
          else:
              columnData = row[i]
          i += 1
  </code></pre>