AnsweredAssumed Answered

Return the largest value from a list

Question asked by Tyler.SmithSRQ on Feb 28, 2020
Latest reply on Mar 2, 2020 by Dan_Patterson

I have a Python script that I am attempting to use to pass the largest value from a list and initialize a counter for sequential ID population.


It has been a long time since I've worked with updatecursors, so please pardon if my code is a bit rusty: 


with arcpy.da.SearchCursor(fc, [fldID]) as rows:
myLst = []
for row in rows:
intlist = [int(s) for s in myLst if s.isdigit()]
print intlist
highestval= max(intlist)
print int(highestval)

for myVal in myLst:
highestval = counter
counter += 1
with arcpy.da.UpdateCursor(fc, [fldID]) as rows:
for row in rows:
row[0] = prefixName + counter

del cursor

The problem is, the ID field is a String and not an integer. an example is wFH0003. I am looking at just grabbing the digits from the string. my max(intlist) is returning an empty value. I want to use this as a script to populate ID's that are null or empty.


Any help would be appreciated.