Return to Snippet

Revision: 48341
at June 30, 2011 01:08 by eristoddle


Updated Code
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

Revision: 48340
at June 29, 2011 06:59 by eristoddle


Initial Code
    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

Initial URL

                                

Initial Description

                                

Initial Title
CSV File Processing

Initial Tags

                                

Initial Language
Python