Solved! Go to Solution.
import arcpy def UpdateTable(table, field): # Start update cursor on table ind = [] start = 1 rows = arcpy.UpdateCursor(table) for row in rows: ind.append(row.getValue(field)) row.setValue(field, ind[0]) start += 1 if start % 2 != 0: ind = [] rows.updateRow(row) del row, rows return test = r'C:\TEMP\New_Points_test\another_Centroid.shp' UpdateTable(test, 'Test') print 'done'
Round(Round( "OBJECTID" , 0) / 2, 0) <> Round( "OBJECTID" , 0) / 2
Round(Round( "OBJECTID" , 0) / 2, 0) = Round( "OBJECTID" , 0) / 2
1 - 1
0 - 1
2 - 2
0 - 2
1 - 1
0 - 1
What you want to do can be accomplished using an update cursor. I do not really understand what you are trying to do though. In your first post you have:
What is the column on the left? Can you explain this a little more? If you just need all rows in pairs of twos to have the same alternating value of 1 or 2, that would be simple with a cursor.
import arcpy def UpdateTable(table, field): # Start update cursor on table ind = [] start = 1 rows = arcpy.UpdateCursor(table) for row in rows: ind.append(row.getValue(field)) row.setValue(field, ind[0]) start += 1 if start % 2 != 0: ind = [] rows.updateRow(row) del row, rows return test = r'C:\TEMP\New_Points_test\another_Centroid.shp' UpdateTable(test, 'Test') print 'done'