I have a table with two elements in this format:
a b
b a
b c
c b
c d
....
f g
g f
I have to analize if the second element is equal to the first element of the following row. If it's true, 1 is set in a new field. If not the marker is added by 1 +1. This is my code so far:
with arcpy.da.SearchCursor(tab_selektiert, ["field1"],) as n1_cur:
with arcpy.da.UpdateCursor(tab_selektiert, ["field2", "markerfield"]) as n_cur:
filler_row = next(n1_cur)
for n_row, n1_row in izip_longest(n_cur, n1_cur, fillvalue=filler_row):
if n1_row[0] == n_row[0]:
n_row1 = counter
n_cur.updateRow(n_row)
else:
numcounter = + 1
n_row1 = counter
n_cur.updateRow(n_row)
del n_cur
del n1_cur
My problem is that beside the search cursor the n_cursor also skip one line. As result I only get b=b, c=c and missing a=b [..]Edit
My results should be something like this:

the field_2[0] and field_1[0](next row value) or field_1[0] and field_2[0](next row value) have to be equal (blue arrows).
If so a marker (started with 1) has to set in the markerfield. In the picuture from line 6 to 7, the continuity makes a step forward and the marker has to update by 1 in line 7. Line 6 has '1' as marker even while the continuity breaks, because 'c' is in linie before.
Edit 2
counter = 1 numberlist = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]with arcpy.da.UpdateCursor(tab_selektiert, (ufield1, ufield2)) as u_cur: with arcpy.da.SearchCursor(tab_selektiert, sfield1) as s_cur: next(s_cur) for sfield1, in s_cur: ufield1, ufield2 = next(u_cur)
print("field 1 " + sfield1 + "---" + " field 2 " + ufield1) print("field 2 + 1 " + str(int(ufield1[-1:]) + int(1))) print("fiel 1 " + str(sfield1[-1:])) print("---") if sfield1 == ufield1: ufield2 = counter elif sfield1[-1] in numberlist and ufield1[-1] in numberlist: if int(ufield1[-1:]) + int(1) == int(sfield1[-1]): ufield2 = counter elif ufield1[-1] == "9" and sfield1[-1] == "0": ufield2 = counter else: counter+=1 ufield2 = counter u_cur.updateRow((ufield1, ufield2))
This gets me to the Point that all fields with a continuity get the marker 1. But a break in the continuity like 'd' to 'f' don't activate the else clause. This fields are just empty, also the last row and the following rows still gets the 1 as marker.