<?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: Syntax of subtype values in codeblock in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131066#M10173</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;then !FTYPE! isn't the field or it is populated with &amp;lt;null&amp;gt; I don't suppose Description would be the field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Aug 2017 15:48:48 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2017-08-23T15:48:48Z</dc:date>
    <item>
      <title>Syntax of subtype values in codeblock</title>
      <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131063#M10170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a pair of data sets with identical schemes; one is a sort of reference layer (A) and the other one is an editable working layer (B). These data sets eventually make their way into a web map for Collector. There is a field using subtypes that help restrict domains for other fields, which looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" height="237" style="border: 1px solid #c6c6c6;" width="161"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef;"&gt;&lt;TH style="width: 38px;"&gt;Code&lt;/TH&gt;&lt;TH style="width: 106px;"&gt;Description&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="width: 38px;"&gt;1&lt;/TD&gt;&lt;TD style="width: 106px;"&gt;Access&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 38px;"&gt;2&lt;/TD&gt;&lt;TD style="width: 106px;"&gt;Anthropocentric&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 38px;"&gt;3&lt;/TD&gt;&lt;TD style="width: 106px;"&gt;Float&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 38px;"&gt;4&lt;/TD&gt;&lt;TD style="width: 106px;"&gt;Generic Karst&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 38px;"&gt;5&lt;/TD&gt;&lt;TD style="width: 106px;"&gt;Other&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 38px;"&gt;6&lt;/TD&gt;&lt;TD style="width: 106px;"&gt;Outcrop&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My workflow includes appending the data in layer (B) to layer (A). The problem is that the subtype field displays its numeric code instead of its description&amp;nbsp;in pop-ups for the web map. For ease of use I need the description to display, so I wanted to calculate the description into a second text field. Eventually this will be a python script, but for testing purposes I've been &lt;STRONG&gt;using the field calculator in ArcMap&lt;/STRONG&gt; to check that the code is right before I incorporate it into my larger script. The below example successfully runs without error, but instead of returning the description in my "if" statement, I'm always getting the "else: nope".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pre-logic script code&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;def myFunc(ftype_int):
 &amp;nbsp;&amp;nbsp;&amp;nbsp;if (ftype_int == 4):
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return "Generic Karst"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;else:
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return "nope"‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Expression&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;myFunc(!FTYPE!)&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In place of the (ftype_int == 4) I've tried (ftype_int == "4"),&amp;nbsp;&lt;SPAN&gt;(ftype_int == "Generic Karst"),&amp;nbsp;(ftype_int == "4 - Generic Karst"), but# have had no luck.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How do I get the field calculator to properly read the values in the subtype field? Hope this makes sense.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:21:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131063#M10170</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2021-12-11T07:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax of subtype values in codeblock</title>
      <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131064#M10171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;instead of printing 'nope' print the value it is returning to make sure it is getting the right field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 15:30:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131064#M10171</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-08-23T15:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax of subtype values in codeblock</title>
      <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131065#M10172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;def myFunc(ftype_int):
 &amp;nbsp;&amp;nbsp;&amp;nbsp;if (ftype_int == 4):
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return "Generic Karst"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;else:
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftype_int‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;myFunc(!FTYPE!)‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hm, modifying my "else" statement to the above&amp;nbsp;gives me a &amp;lt;NULL&amp;gt; value in my&amp;nbsp;FTYPE field.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:21:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131065#M10172</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2021-12-11T07:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax of subtype values in codeblock</title>
      <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131066#M10173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;then !FTYPE! isn't the field or it is populated with &amp;lt;null&amp;gt; I don't suppose Description would be the field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 15:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131066#M10173</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-08-23T15:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax of subtype values in codeblock</title>
      <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131067#M10174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are only the two fields: "ftype_int" which is the 'short' field that has the subtype values, and "ftype" which is the 'text' field I'm trying to calculate to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plugging in some of the other unrelated fields from the table into my "else" statement, I've noticed that everything gives me a &amp;lt;Null&amp;gt; value for my ftype field. The only thing that hasn't given me a &amp;lt;Null&amp;gt; return is telling it to print something specific like "nope".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for taking the time&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 16:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131067#M10174</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2017-08-23T16:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax of subtype values in codeblock</title>
      <link>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131068#M10175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up using another method because I just couldn't figure out what the heck was wrong here. Didn't seem to be able to read&amp;nbsp;&lt;EM&gt;any&lt;/EM&gt; field I tried, so must not be an issue specific to subtype. Instead I broke it into two steps: calculated the numeric codes into my string field, then used the .replace() function to swap out the codes and descriptions. Would still be curious to know why I couldn't get the if/else statements to work, though.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2017 19:55:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-of-subtype-values-in-codeblock/m-p/131068#M10175</guid>
      <dc:creator>AaronKoelker</dc:creator>
      <dc:date>2017-08-23T19:55:16Z</dc:date>
    </item>
  </channel>
</rss>

