axeceau = "RHAXECEL" # the feature class fields = ['CODHYDRO', 'TYPECEAU'] # TYPECEAU is the subtype field with arcpy.da.UpdateCursor(axeceau, fields) as cursor8: for row in cursor8: if row[0] == 3: row[1] = 4 elif row[0] == 4: row[1] = 1 elif row[0] == 5: row[1] = 1 else: row[1] = 1 cursor8.updateRow(row)
Solved! Go to Solution.
try: axeceau = "RHAXECEL" fields = ['CODHYDRO', 'TYPECEAU'] edit = arcpy.da.Editor(arcpy.env.workspace) with arcpy.da.Editor(arcpy.env.workspace) as edit: cursor8 = arcpy.da.UpdateCursor(axeceau, fields) #rows = arcpy.UpdateCursor(axeceau, fields) for row in cursor8: if row[0] == 3: row[1] = 4 elif row[0] == 4: row[1] = 1 elif row[0] == 5: row[1] = 1 else: row[1] = 1 cursor8.updateRow(row) except arcpy.ExecuteError: print(arcpy.GetMessages(2))
What doesn't work? What error do you get.
Have you already defined what subtypes 1 & 4 are?
Cheers,
Neil
try: axeceau = "TOP10_SIG.DBO.RHAXECEL" fields = ['CODHYDRO', 'TYPECEAU'] with arcpy.da.UpdateCursor(axeceau, fields) as cursor8: #rows = arcpy.UpdateCursor(axeceau, fields) for row in cursor8: if row[0] == 3: row[1] = 4 elif row[0] == 4: row[1] = 1 elif row[0] == 5: row[1] = 1 else: row[1] = 1 cursor8.updateRow(row) except arcpy.ExecuteError: print(arcpy.GetMessages(2))
try: axeceau = "RHAXECEL" fields = ['CODHYDRO', 'TYPECEAU'] edit = arcpy.da.Editor(arcpy.env.workspace) with arcpy.da.Editor(arcpy.env.workspace) as edit: cursor8 = arcpy.da.UpdateCursor(axeceau, fields) #rows = arcpy.UpdateCursor(axeceau, fields) for row in cursor8: if row[0] == 3: row[1] = 4 elif row[0] == 4: row[1] = 1 elif row[0] == 5: row[1] = 1 else: row[1] = 1 cursor8.updateRow(row) except arcpy.ExecuteError: print(arcpy.GetMessages(2))