<?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: Replace Null Value - Field Calc, Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370282#M29290</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked well. Thanks for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Oct 2018 20:14:09 GMT</pubDate>
    <dc:creator>KeithSoRelle</dc:creator>
    <dc:date>2018-10-01T20:14:09Z</dc:date>
    <item>
      <title>Replace Null Value - Field Calc, Python</title>
      <link>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370279#M29287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trying to replace a null value with the field calculator. I am have a script that appends multiple feature classes into one feature class. After each feature class appends I want to add a field&amp;nbsp;calculateField_management (field calculator) statement run that makes all null values from a specific field into a string value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried a number of ways but have yet to get an expected result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 values for in the field - Null, 'CFW' and need to replace Null with 'TAR'.&lt;/P&gt;&lt;P&gt;Then I will have 3 values - Null, 'CFW', 'TAR' and will need to replace Null with 'DEN'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been trying something along the lines of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def myCalc(x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (x != 'CFW"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 'TAR'&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 'CFW'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should be simple but I haven't had much luck getting the expected response. Could use help on both field calculations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Keith&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2018 18:13:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370279#M29287</guid>
      <dc:creator>KeithSoRelle</dc:creator>
      <dc:date>2018-10-01T18:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Null Value - Field Calc, Python</title>
      <link>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370280#M29288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;if x is None:&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;&amp;nbsp; &amp;nbsp; do something&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should work if it is truly none and not just an empty string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or to cover all bases (add more to the tuple if needed&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;if x in (None, "", " ", "nadda"):&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;&amp;nbsp; &amp;nbsp; do something&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2018 18:17:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370280#M29288</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-10-01T18:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Null Value - Field Calc, Python</title>
      <link>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370281#M29289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use Python&lt;A href="https://docs.python.org/3.6/reference/expressions.html#conditional-expressions"&gt; Conditional expressions&lt;/A&gt;, a.k.a., ternary operators, to accomplish this task on one line.&amp;nbsp; Set the parser to Python and put the following in the expression box:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;'TAR'&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; !Field! &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; None &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; !Field!&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;Swap &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;!Field!&lt;/SPAN&gt; above for your field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2018 18:22:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370281#M29289</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-10-01T18:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Null Value - Field Calc, Python</title>
      <link>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370282#M29290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked well. Thanks for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2018 20:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-null-value-field-calc-python/m-p/370282#M29290</guid>
      <dc:creator>KeithSoRelle</dc:creator>
      <dc:date>2018-10-01T20:14:09Z</dc:date>
    </item>
  </channel>
</rss>

