AnsweredAssumed Answered

Problem in Inserting Row in shape file using Python,

Question asked by on Dec 9, 2014
Latest reply on Dec 10, 2014 by

Complete problem to solve ?

Write a script that adds a text field to the roads.shp feature class called FERRY and populates this field with YES and NO values, depending on the value of the FEATURE field.

Below is my code, but i got an error (" sequence size must match size of the row "), Please help me...


fc = "roads.shp"

newfield = "FERRY"

fieldtype = "TEXT"

fieldname = arcpy.ValidateFieldName(newfield)

fieldlist = arcpy.ListFields(fc)



if fieldname not in fieldlist:

    arcpy.AddField_management(fc, fieldname, fieldtype, "", "", 12)

    print "New field has been added."


    print "Field name already exists."



cursor = arcpy.da.UpdateCursor(fc, ["FEATURE","FERRY"])



for row in cursor:

    if row[0] == "Ferry Crossing":

        #print row[0]


        row[1] = "YES"


        #print row[0]


        row[1] = "NO"


del row

del cursor