jahood

Calculating a Text field with value from list

Discussion created by jahood on Nov 22, 2011
Latest reply on Nov 22, 2011 by mzcoyle
I tried using a straight up arcpy.calculate_field and it didnt work.   So Then I switched to an update cursor but it still does not work!

It gives me errors such as "Cannot calculate field: Invalid Character" etc.
In all cases the field in question remains null and never gets a value.

Here is a snip of the code in question:
(This code clips 5 FC's with 3 other FC's.  Then it adds the field and calculates it...

#features is  a list of shapefiles
features = [water_point, cutoffpoint, reclaimationline, accessline, ch_mergepoint] 
trap_list = ["trap_1", "trap_2", "trap_3"]
shapelist =[]
for trap in trap_list:
    for layer in features:
        # Process: Clip
        current = directory + "_" + trap + "_" + layer+".shp"
        arcpy.Clip_analysis(directory + layer +".shp", directory + trap +".shp", current, "")
        # Process: Add Field
        arcpy.AddField_management(current, "TPA_NUM", "TEXT", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")
        
        update_cursor = arcpy.UpdateCursor(current)
        while row in update_cursor:
            string = str(trap)
            row.TPA_NUM = string
            update_cursor.updateRow(row)



print "end"


Any thoughts on why its having difficulty reading the string out of the list and then inserting it into the update cursor or into a calculate field tool?

Outcomes