I am having some trouble getting a search cursor to return a value for each record. The purpose of my code is to scan through a list of records in a field (FieldA) and based on those values populate a second field (FieldB) with a random number between 1 and the value in FieldA. FieldA contains numeric values which vary depending on their association. My code is as follows:
CursorA = arcpy.SearchCursor(FC) for row in cursorA: rowcount =(row.getValue("FieldA")) row = cursorA.next() cursorB = arcpy.UpdateCursor(FC, "FieldB") for rowB in cursorB: rowB = randint(1, rowcount) cursorB.updateRow(rowB)
When I run the code it appears as though the searchcursor locates the value of the last record in FieldA and uses that value as the highest value in the random sequence. I could be wrong on this however, and it could be related to improper coding on my part.