<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Field for Label Expression  - no recognized?? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289208#M22423</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Line 8 refers to this line&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14223909684365302 jive_text_macro" jivemacro_uid="_14223909684365302"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = S2[0] + '\n' + S2[1]&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just before that you check the length of list S. Maybe you should also check the length of list S2. If it is 1, "S2[1]"&amp;nbsp; will generate the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if NANAME does not have a space and after the split results in a list with 1 item, it will generate the error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Jan 2015 20:36:36 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2015-01-27T20:36:36Z</dc:date>
    <item>
      <title>Field for Label Expression  - no recognized??</title>
      <link>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289206#M22421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI All,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issue with it is this:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; As mentioned if I remove [NANAME] or just put [OWNER_NAME] before [NANAME] it will run but does not produce the desired results.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="python" name="code"&gt;def FindLabel ([NANAME], [OWNER_NAME] ): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text = [NANAME] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text2 = [OWNER_NAME]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = text.split(',') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S = text.split(', ') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(S) == 1: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = S[0].split(' ', 1) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = S2[0] + '\n' + S2[1] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = S[0] + ',\n' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABBREV = '' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S3 = S[1].split(' ') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each in S3: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not each in ('&amp;amp;', 'AND'): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABBREV = ABBREV + each[0:1] + '. ' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ABBREV = ABBREV + each[0:1] + ' ' &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = S2 + ABBREV[0:-1]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return S2 &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your ideas:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 20:19:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289206#M22421</guid>
      <dc:creator>MikeBly</dc:creator>
      <dc:date>2015-01-27T20:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Field for Label Expression  - no recognized??</title>
      <link>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289207#M22422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Forgot to mention - the error I receive:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"File "&amp;lt;string&amp;gt;", line 8, in FindLabel&lt;/P&gt;&lt;P&gt;IndexError:list index out of range"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 20:23:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289207#M22422</guid>
      <dc:creator>MikeBly</dc:creator>
      <dc:date>2015-01-27T20:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Field for Label Expression  - no recognized??</title>
      <link>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289208#M22423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Line 8 refers to this line&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14223909684365302 jive_text_macro" jivemacro_uid="_14223909684365302"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S2 = S2[0] + '\n' + S2[1]&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just before that you check the length of list S. Maybe you should also check the length of list S2. If it is 1, "S2[1]"&amp;nbsp; will generate the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if NANAME does not have a space and after the split results in a list with 1 item, it will generate the error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 20:36:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-for-label-expression-160-no-recognized/m-p/289208#M22423</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-27T20:36:36Z</dc:date>
    </item>
  </channel>
</rss>

