AnsweredAssumed Answered

Field for Label Expression  - no recognized??

Question asked by mbly29 on Jan 27, 2015
Latest reply on Jan 27, 2015 by xander_bakker

HI All,


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[0].split(' ', 1)           S2 = S2[0] + '\n' + S2[1]      else:           S2 = S[0] + ',\n'           ABBREV = ''           S3 = S[1].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: