I would like to know how I can compare data in two consecutive rows in a feature class. I want to compare data in two consecutive rows and based on this comparison decide if I want to delete the first row in the pair. See example below.
table ------------- id col_a col_b col_c row-1 1 dog red sad row-2 2 dog red happy row-3 3 cat black mad
logic ------------- a = get_first b = get_next
for each row in table: if a.col_a = b.col_a: delete a a = b b = get_next
If I use a cursor where I say a = cur.next() and b=cur.next() they both end up pointing to the second object fetched from the cursor. I can't seem to figure out how to peek into the next row in a table without advancing the cursor pointer. In Oracle there are Lead / Lag functions that let you look at the next / previous rows in a table. Any advice would be greatly appreciated. Thanks in advance.
Perhaps use the first loop to simply gather all the OIDs for the rows that need to be deleted and then use another loop to delete them, or use DeleteRows_management (following a MakeFeatureLayer_management with SQL expression built from the OIDs).