I'm trying to update rows using the update cursor, but based on the number of rows in a sequence of three list items. Looking at the list below, it needs to update first four rows to 'B', then the next 9 rows to 'D' and then the next 14 rows to 'A'.
I've gotten as far as the code below, but all I'm getting is an update of the first four to 'B' and then I get 5 calculated to 'D' and then another 5 to 'A'. I think it's going back to the start of the table somehow.
RowCount = 1 lenClusters = [4,9,14] # number of rows to update in that sequence. rows = arcpy.UpdateCursor(fcPhotos, "", "", "CapturedStatus") for row in rows: if rowCount > 0 and rowCount <= lenClusters: # See if the current rowCount is from 1 to 4 row.CapturedStatus = "B" elif rowCount > lenClusters and rowCount <= lenClusters: # See if the current rowCount is from 5 to 9 row.CapturedStatus = "D" elif rowCount > lenClusters and rowCount <= lenClusters: # See if the current rowCount is from 10 to 27 row.CapturedStatus = "A" rows.updateRow(row) rowCount += 1
I also can't rely on the row ID as it might have missing IDs.