Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Random Value Generator

$
0
0

I have a python code where I am trying to assign a unique, random value to every row. I have tried:

maxvalue = int(arcpy.GetCount_management(shape).getOutput(0)) + 10000
for row in arcpy.SearchCursor(shape, fields="FID"):
     insert = randint(0, maxvalue)
     arcpy.CalculateField_management(shape, "RNDM", '"' + str(insert) + '"', "VB")

but to no avail. I keep getting only 1 value for all rows. I have looked at other resources, but the answer still eludes me (e.g. https://geonet.esri.com/thread/96917). This method is as well extremely slow.


Viewing all articles
Browse latest Browse all 767

Trending Articles