theRow, theRows = None, None theRows = arcpy.da.UpdateCursor(UCU_arc, ['LEFT_FID', 'RIGHT_FID', 'LUCU', 'RUCU', 'LGeoDetail', 'RGeoDetail', 'LUnitSub', 'RUnitSub', 'LSubMinor', 'RSubMinor', 'LMinorSpecific', 'RMinorSpecific', 'LineID']) # The values to be using the the 10.1 cursor: # LEFT_FID and RIGHT_FID: theRow[0], theRow[1] # LUCU and RUCU: theRow[2], theRow[3] # LGeoDetail and RGeoDetail: theRow[4], theRow[5] # LUnitSub and RUnitSub: theRow[6], theRow[7] # LSubMinor and RSubMinor: theRow[8], theRow[9] # LMinorSpecific and RMinorSpecific: theRow[10], theRow[11] # LineID : theRow[12] # ArcGIS 10.0 version.... # theRow = theRows.next() # for theRow in theRows: # if ((theRow.LEFT_FID == -1) or (theRow.RIGHT_FID == -1)): # theRow.LineID = 6000 # theRows.updateRow(theRow) # elif ((theRow.LUCU == theRow.RUCU) and (theRow.LGeoDetail == 5 or theRow.RGeoDetail == 5)): # theRow.LineID = 4000 # theRows.updateRow(theRow) # elif ((theRow.LUCU == theRow.RUCU) and (theRow.LGeoDetail == 9 or theRow.RGeoDetail == 9)): # theRow.LineID = 4000 # theRows.updateRow(theRow) # elif ((theRow.LUCU == theRow.RUCU) and (theRow.LGeoDetail == 6 or theRow.RGeoDetail == 6)): # theRow.LineID = 5000 # theRows.updateRow(theRow) # elif (theRow.LUnitSub != theRow.RUnitSub): # theRow.LineID = 1000 # theRows.updateRow(theRow) # elif (theRow.LSubMinor != theRow.RSubMinor): # theRow.LineID = 2000 # theRows.updateRow(theRow) # elif ((theRow.LSubMinor == theRow.RSubMinor) and (LMinorSpecific != RMinorSpecific)): # theRow.LineID = 3000 # theRows.updateRow(theRow) # else: # theRow.LineID = 9000 # print LineID, LUCU, RUCU # theRow = theRows.next() #theRow = theRows.next() for theRow in theRows: if ((theRow[0] == -1) or (theRow[1] == -1)): theRow[12] = 6000 theRows.updateRow(theRow) elif ((theRow[2] == theRow[3]) and (theRow[4] == 5 or theRow[5] == 5)): theRow[12] = 4000 theRows.updateRow(theRow) elif ((theRow[2] == theRow[3]) and (theRow[4] == 9 or theRow[5] == 9)): theRow[12] = 4000 theRows.updateRow(theRow) elif ((theRow[2] == theRow[3]) and (theRow[4] == 6 or theRow[5] == 6)): theRow[12] = 5000 theRows.updateRow(theRow) elif (theRow[6] != theRow[7]): theRow[12] = 1000 theRows.updateRow(theRow) elif (theRow[8] != theRow[9]): theRow[12] = 2000 theRows.updateRow(theRow) elif ((theRow[8] == theRow[9]) and (theRow[10] != theRow[11])): theRow[12] = 3000 theRows.updateRow(theRow) else: theRow[12] = 9000 print theRow[12], theRow[4], theRow[5] #finally: # Regardless of whether the script succeeds or not, delete # the row and cursor # if theRow: del theRow if theRows: del theRows
Solved! Go to Solution.
else: theRow[12] = 9000 print theRow[12], theRow[4], theRow[5]
with arcpy.da.UpdateCursor(UCU_arc, ['LEFT_FID', 'RIGHT_FID', 'LUCU', 'RUCU', 'LGeoDetail', 'RGeoDetail', 'LUnitSub', 'RUnitSub', 'LSubMinor', 'RSubMinor', 'LMinorSpecific', 'RMinorSpecific', 'LineID']) as theRows: for theRow in theRows: <insert code>
else: theRow[12] = 9000 print theRow[12], theRow[4], theRow[5]
with arcpy.da.UpdateCursor(UCU_arc, ['LEFT_FID', 'RIGHT_FID', 'LUCU', 'RUCU', 'LGeoDetail', 'RGeoDetail', 'LUnitSub', 'RUnitSub', 'LSubMinor', 'RSubMinor', 'LMinorSpecific', 'RMinorSpecific', 'LineID']) as theRows: for theRow in theRows: <insert code>