I have a Forest roads here with me and there is a column (iD ) that shows street name number, freeway, state, county along with their numbers..
I copied them to a new field column Symbol that I need to calculate them with just numbers only.
This purpose is to show them the road symbol number as a labels
How do I do that in the Field Calculator ?
>>> a = "MIA-45.678"
>>> b = float(''.join(ele for ele in a if ele.isdigit() or ele == '.'))
>>> b
45.678
I tried and didn't work either and I was wondering if that had to do with the new version each time ESRI upgraded their ESRI products and we all have to re-learn new things and that is CRAZY !!!!
You are using the python parser aren't you? Arc* defaults to vb-whatever and you can't set python as the default. Eventually, they will get it fixed.
Just curious - any idea if the suggestion of allowing the setting of the default to Python (instead of VB script) has been submitted to ESRI already as an enhancement?
Chris Donohue, GISP
quite some time ago... so long ago, that I can't find it
Hello Robert,
If I understand your situation correctly and you want to take a non-script approach I think you could do that fairly easily with some preprocessing to separate out the "pure" numbers (e.g., "111" in your snapshot) from the "mixed format" numbers (e.g., "PRK-70"). The "pure" ones are a piece of cake; just add your new numeric field and use the Field Calculator to copy in the numbers. If they were all "pure" you'd be done; but, alas, they aren't. So, for these you can use an intermediate text field, some selection sets and VBA functions (e.g., RIGHT). Don't see what you intend to do with the ones that don't have any number in them except leave them 0. Of course, you may want to create a text Symbol field that just leaves off the state, county and other values embedded in your ID field. If you expect to do this repeatedly or want to practice scripting, you should definitely go the script route, but if it's a one-off thing and you just want it done, the VBA process should work just fine.
Check out this Knowledge Base Technical Article for VBA functions. I'm using ArcGIS 10.3 and they still work for me. Good luck.