I am trying to make labels for all the named peaks across British Columbia. The name string in the attribute table has many entries like "Rad, Mount" or "Rad Peak, The", and I'd like to display them on the map as "Mount Rad" or "The Rad Peak". There are about 13,000 features in the table with only maybe a quarter that need to be changed.
Any suggestions on the best way to accomplish this?
Solved! Go to Solution.
GOT IT! Thanks Dan!
After getting it to work in the field calculator I put this in to the label field expression and it seems to be working
Ahhh a brain nimbler...
replace fld with your source field name in ! marks ie !YourField!
Python parser, in the field calculator for a new text field obviously
# ---- a sample 'field'
fld = ["Last, First", "Ok", "two last, first", "right order", "Rad Peak, The"]
# ---- the field calculator expression, python parser
[[i, " ".join(i.split(", ")[::-1])][", " in i] for i in fld ]
# ---- result
['First Last', 'Ok', 'first two last', 'right order', 'The Rad Peak']
might not work in all circumstances, so try it on a few and worry about the corner cases later