I need to create an ID that includes the year, county and sequential number. The sequential number or the county makes the id different
So
if year 2013, county 001 - the sequential number is 001 and unique id is 2013-001-001
if year 2013, county 001 - the sequential number is 002 and unique id is 2013-001-002
If year 2014, county 001 - sequential number is 001 and unique id is 2014-001-001
If year 2014, county 005 - sequential number is 001 and unique id is 2014-005-001
I already have the code to calculate the sequential number but now it is just calculating the numbers from 001, 002, 003 for the fields when sorted by the sequential number field. Is there a way to create the sequential number based on year and county ? Thank you
So
if year 2013, county 001 - the sequential number is 001 and unique id is 2013-001-001
if year 2013, county 001 - the sequential number is 002 and unique id is 2013-001-002
If year 2014, county 001 - sequential number is 001 and unique id is 2014-001-001
If year 2014, county 005 - sequential number is 001 and unique id is 2014-005-001
I already have the code to calculate the sequential number but now it is just calculating the numbers from 001, 002, 003 for the fields when sorted by the sequential number field. Is there a way to create the sequential number based on year and county ? Thank you
Code:
arcpy.SelectLayerByAttribute_management("Stewardship", "CLEAR_SELECTION")
filter = 'NOT SequenceNumber IS NULL' #filter for non-Null values
cur1 = arcpy.UpdateCursor("Stewardship", filter, "", "", "SequenceNumber A")
# Iterate through rows and get highest ID values
high_id = 0
for row1 in cur1:
if high_id < row1.SequenceNumber:
high_id = row1.SequenceNumber
filter = 'SequenceNumber IS NULL' #filter for Null values
cur2 = arcpy.UpdateCursor("Stewardship", filter)
# Iterate through rows and update values
i = high_id
for row2 in cur2:
i += 1
row2.SequenceNumber = (i)
cur2.updateRow(row2)