/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def processCsv(self): fileName = self.progPath + "\\csv\\" + self.fileToRun thisCsv = csv with open(fileName, "rb") as f: try: rownum = 0 for row in thisCsv.reader(f, delimiter = ",", quotechar = '"'): if rownum == 0: header = row else: colnum = 0 for col in row: print '%-8s: %s' % (header[colnum], col) if (header[colnum] == "Submit Date"): orderdate = self.extractDate(header[colnum]) if (header[colnum] == "Customer"): processedName = self.splitName(col) firstname = processedName[1] lastname = processedName[0] colnum += 1 #self.findOrder(firstname, lastname, orderdate) rownum += 1 except thisCsv.Error, e: sys.exit('file %s: %s' % (fileName, e)) pass