I have ZERO experience with ArcPy, Arcade expressions... yadda yadda. I basically limp along until something magically works and I'm a huge fan of Copy/Paste. THAT SAID, I'm dipping my toe into something that I thought would be easy...
I have a bunch of campgrounds, and these are in some parks. I want to give them sequential values based on sorting the PARK_NAME field alphabetically. Using Python 3 in Field Calculator, "Sequential Number" will only assign sequential values based on the Object ID field - it doesn't care how I've sorted it.
How do I tell it to use my sorted field instead of the Object ID? Help!
/blogs/dan_patterson/2018/02/12/table-tools-a-set-of-tools-for-working-with-tabular-data is a description to the Code sharing site for my set of table tools.
Calculations for text fields may be what you are looking for... but a better example of your desired output might help
Alrighty in this table I've run the Sequential python 3 straight from the calculate field options and this is sorted ascending OID. You can see that the sequential values were assigned by the OID. I don't want this:
In this next screen shot, I've ordered park name ascending by alphabet. I would prefer that the CampgroundID would then be "001, 002, 003", but it's not...
Does this help explain what I'm looking for? Just downloaded Table Tools!!
let me know if it works or you have any issues... I never got many applicable test cases … it was more an exercise in coding
Hey Dan,
So I'm circling back around to this item. I've got table tools and I ran Text Fields and keep getting this error:
Traceback (most recent call last):
File "c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Scripts\sequential_funcs_txt.py", line 199, in <module>
in_tbl, in_arr, in_fld, out_fld, del_fld, func, xtend = _tool()
File "c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Scripts\sequential_funcs_txt.py", line 185, in _tool
in_arr = tbl_2_np_array(in_tbl, flds)
NameError: name 'tbl_2_np_array' is not defined
Failed to execute (TxtFieldCalculations).
like sequential number text fields?
Yes! Exactly. I keep trying to run this - even trying different tables - and it is giving me the above error.
I will check the version online... had some issues with things not being updated. I have attached a zip... try it
unzip into a folder and run from there.
don't separate anything and make sure the destination folder has no spaces (i don't tolerate them)
if this doesn't work, zip and email a copy of the table in a gdb (remove fluff and anonymize if needed) and I will have a look at it.
Ok, interesting! So I took the same layer and threw it into the toolbox from your zip file. This is a layer in an Enterprise Geodatabase that I have full editing privileges to. It said that it failed because it didn't want to work outside of an edit session (I'm working in ArcGIS Pro 2.2.4)... so I exported out the feature layer to the project geodatabase and ran the tool and it worked fine. Hmmm.
Work local. Enterprise is for Star Trek. You can get a full refund if you aren't satisfied