AnsweredAssumed Answered

Is there a way to derive values using the Search Cursor and then update another field with those values?

Question asked by RP.CObb on Oct 10, 2019
Latest reply on Oct 11, 2019 by RP.CObb



So I have a slight predicament for this given scenario. I need to take the last 4 characters from the x coordinate and do the same for the y coordinate. I then need to combine the two and from the combined values, update another field. I have something akin but I keep running into errors. I can get it to list a set of values that I need but trying to get the update cursor to update the records in the field is tricky.


if == 'FACILITY_ID':

            for row in arcpy.da.SearchCursor(fc, ["FACILITY_ID", "SHAPE@X", "SHAPE@Y"], """FACILITY_ID IS NULL"""):
                rowx = str(row[1])
                rowy = str(row[2])
                x = rowx[0:4]
                y = rowy[0:4]
                xy = x + y
            for row in arcpy.da.UpdateCursor(fc, ["FACILITY_ID"], """FACILITY_ID IS NULL"""):
                print '{} = {}'.format(, xy)

Any help on this would be greatly appreciated.