I am having difficulty getting to grips with arcpy and cursors. What i aim to do is the following: Depending on the direction specified in Test I wish to update the Target field. If it is forward, the Target should receive the Value of AP from the next row/feature. In this example for the first feature, the Target would be 2. Aditionally, if the direction specified is backward the Target field should receive the value from the previous row. To make matters worse, the AP and Target fields are strings (and converting them is not an option as the data provided in ususally alphanumeric), so simply adding and subtracting 1 is not possible.
what i have so far:
i = 0 lastvalue =  with arcpy.da.SearchCursor(InFC, [Direction, AP]) as cursor: for row in cursor: if Direction == "forward": newField = AP[row+1] ## here id like to reference the next value somehow else: newField = AP[row-1] ## here id like to reference the previous value