In this example, how do I write a Python script to accomplish this result:
Site ID
SIte A 0001
Site A 0001
SIte A 0001
Site A 0001
Site B 0002
SIte B 0002
Site B 0002
Site C 0003
SIte D 0004
I am suspecting that there is more to it than that.
This is in connection with post: "Sequential Numbering Python Script for
Field Calculator in Arc 10.2" but a different sequence in the data.
Thanks,
Charles Banks
Well it can be done easily in more recent versions ( Table tools for ArcGIS PRO )
but perhaps if you included the link someone with an older version of ArcMap (or even 10.6) could have a look at what was posted there
The link is "
I don't have Pro and I would have to do this from Field Calc.
Thanks
Charles
The code I posted is in that link... you just need to change the field name that contains the source classification
seq_count(!Test!)
in that thread's example the Site stuff was in a field called Test.
You just need to do a field calculation with seq_count as the Code block and the seq_count(!YourFieldName!) as the expression.
Of course, you have to set the field calculator to the python parser
This script does not produce the sequence above, it does work though!
It doesn't produce the exact sequence because... your data are different I suspect.
Perhaps you should show the data you are trying to produce a sequence for... or are you not following what the script does exactly?
This is a sample of what needs to be:
FIELD | NEED TO BE |
xxx_ 9999TUNK10_ | xxx_ 9999TUNK10_001 |
xxx_ 9999TUNK10_ | xxx_ 9999TUNK10_001 |
xxx_ 9999TUNK10_ | xxx_ 9999TUNK10_001 |
xxx_ 9999BANK12_ | xxx_ 9999BANK12_002 |
xxx_ 9999BANK17_ | xxx_ 9999BANK17_003 |
xxx_ 9999BANK1_ | xxx_ 9999BANK1_004 |
xxx_ 9999BANK20_ | xxx_ 9999BANK20_005 |
xxx_ 9999BANK20_ | xxx_ 9999BANK20_005 |
xxx_ 9999BANK20_ | xxx_ 9999BANK20_005 |
xxx_ 9999BANK30_ | xxx_ 9999BANK30_006 |
did you substitute the !Test! name in the field calculator expression and try what I suggested?
perhaps you can take a screen grab of the field calculator dialog so we can see what you are doing