How do I use a value from a query table to be my starting value(pStart) in the auto increment code below:
rec=0 def autoIncrement(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec += pInterval return rec
We are gathering statistics from a table using the max function, we need that max value to be the starting point for our auto increment. How do we use that value as the pStart?
Hi Jenneth,
Not sure if this will be possible with ModelBuilder. The Summary Stats tool creates a table output. You will have to iterate the table to extract the value to a variable that you can pass to the CalculateField function.
You can export your ModelBuilder to Python by going to Model > Export > To Python Script. Next, use a SearchCursor to iterate the output table from the Summary Stats tool. Ex:
with arcpy.da.SearchCursor(summaryStatsTable, ["MAX_VALUE_FIELD"]) as cursor:
for row in cursor:
maxValue = row[0]
del cursor
You can then pass the maxValue variable to the CalculateField function.