I am attempting to take multiple field attributes with a specific classification/moniker (in this case-- any attribute field containing a value with SAS-06-xxxxx), and replace them with classification more in line with the rest of the attributes (Ascending sequential values up from SAS-02-05700 as a starting point). What would the python syntax look like in the code block using Field Calculator. Novice with Python, so any help/feedback is appreciated. Thx.
Solved! Go to Solution.
Select the unwanted rows with Select Layer By Attribute or with a definition query
Use this with Calculate Field (This changes the data, make a backup!)
# ID =
next_sas_02_sequence()
# Code Block
sas_counter = 5700
def next_sas_02_sequence():
global sas_counter
sas_02_sequence = f"SAS-02-{sas_counter:05}"
sas_counter += 1
return sas_02_sequence
Select the unwanted rows with Select Layer By Attribute or with a definition query
Use this with Calculate Field (This changes the data, make a backup!)
# ID =
next_sas_02_sequence()
# Code Block
sas_counter = 5700
def next_sas_02_sequence():
global sas_counter
sas_02_sequence = f"SAS-02-{sas_counter:05}"
sas_counter += 1
return sas_02_sequence
Thanks Johannes, this was very easy to follow and navigate. I tested on a dummy set first, and it worked! Much appreciated with the feedback and screenshots. You just reinforced my belief I need to brush up/build on my Python skills. Cheers!