Posted By

eristoddle on 06/29/11


Tagged

pythoncsv


Versions (?)

CSV File Processing


 / Published in: Python
 

  1. def processCsv(self):
  2. fileName = self.progPath + "\\csv\\" + self.fileToRun
  3. thisCsv = csv
  4. with open(fileName, "rb") as f:
  5. try:
  6. rownum = 0
  7. for row in thisCsv.reader(f, delimiter = ",", quotechar = '"'):
  8. if rownum == 0:
  9. header = row
  10. else:
  11. colnum = 0
  12. for col in row:
  13. print '%-8s: %s' % (header[colnum], col)
  14. if (header[colnum] == "Submit Date"):
  15. orderdate = self.extractDate(header[colnum])
  16. if (header[colnum] == "Customer"):
  17. processedName = self.splitName(col)
  18. firstname = processedName[1]
  19. lastname = processedName[0]
  20. colnum += 1
  21. #self.findOrder(firstname, lastname, orderdate)
  22. rownum += 1
  23. except thisCsv.Error, e:
  24. sys.exit('file %s: %s' % (fileName, e))
  25. pass

Report this snippet  

You need to login to post a comment.