AnsweredAssumed Answered

csv.reader to updateCursor

Question asked by EscondidoAnalyst on May 1, 2018
Latest reply on Feb 5, 2019 by vangelo-esristaff

How do I modify my syntax to properly read an csv file and write the contents to a shapefile using an update cursor ?


# Read csv file & write to shapefile via update cursor
import csv,os

updateCursor = arcpy.da.UpdateCursor(r'sample.shp', ["Name", "OrderCount","Time","Miles"])

with open(r'CsvToShape.csv','rb') as f:
    reader = csv.reader(f)
    for row in reader:
        route = row[0]
        order = row[1]
        time = row[2]
        mile = row[3]
        for row in updateCursor:
                row.setValue(route = Name)
##                row[1]= order
##                row[2] = time
##                row[3] = mile