I have a small label expression code written with the help of folks on here - it has been working great for the last couple of years. Simply, it splits the string and abbreviates the text (names).
Issue with it is this:
I have a polygon FC that I label with landowner names - when I label the FC by simply selecting the field name ([NANAME]) to be the label field, the labels appear as expected, basic labeling 101. When I use this same field in an expression using python as my parser it will no longer work.
There is a second field in the table that also contains owner names ([OWNER_NAME]). In the expression, if I replace NANAME with OWNER_NAME the expression will be successful, otherwise it fails. Both fields are STRING. As mentioned if I remove [NANAME] or just put [OWNER_NAME] before [NANAME] it will run but does not produce the desired results.
The only difference from when this was working successfully and now is that I believe I was running ArcGIS 10.0 and now running 10.1.
def FindLabel ([NANAME], [OWNER_NAME] ): text = [NANAME] text2 = [OWNER_NAME] S2 = text.split(',') S = text.split(', ') if len(S) == 1: S2 = S.split(' ', 1) S2 = S2 + '\n' + S2 else: S2 = S + ',\n' ABBREV = '' S3 = S.split(' ') for each in S3: if not each in ('&', 'AND'): ABBREV = ABBREV + each[0:1] + '. ' else: ABBREV = ABBREV + each[0:1] + ' ' S2 = S2 + ABBREV[0:-1] return S2
Thanks for your ideas: