title: Python script reading from a csv file
body: <pre><code>           "Type","Name","Description","Designation","First-term assessment","Second-term assessment","Total"
             "Subject","Nick","D1234","F4321",10,19,29
             "Unit","HTML","D1234-1","F4321",18,,
             "Topic","Tags","First Term","F4321",18,,
             "Subtopic","Review of representation of HTML",,,,,
  </code></pre>
  
  <p>All the above are the value from an excel sheet , which is converted to csv and that is the one shown above</p>
  
  <p>The header as you notice contains seven coulmns,the data below them vary,</p>
  
  <p>I have this script to generate these from python script,the script is below</p>
  
  <pre><code> from django.db import transaction
   import sys
   import csv
   import StringIO
  
  
  
   file = sys.argv[1]
   no_cols_flag=0
   flag=0
   header_arr=[]
  
  
   print file
   f = open(file, 'r')
  
  
  
  while (f.readline() != ""):
    for i in [line.split(',') for line in open(file)]: # split on the separator
      print "==========================================================="
      row_flag=0
      row_d=""
      for j in i: # for each token in the split string
        row_flag=1
        print j
  
  
        if j:
          no_cols_flag=no_cols_flag+1
          data=j.strip()
          print j
  
      break
  </code></pre>
  
  <p>How to modify the above script to say that this data belongs to a particular column header..</p>
  
  <p>thanks..</p>