<?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: Python if statement in arcpy.CalculateField_management isn't working? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8756#M320</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for both your responses, I've tried Joshua's suggestion and the script has ran through perfectly, just what I needed.&amp;nbsp; Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Dec 2016 11:13:00 GMT</pubDate>
    <dc:creator>MichaelRamm</dc:creator>
    <dc:date>2016-12-13T11:13:00Z</dc:date>
    <item>
      <title>Python if statement in arcpy.CalculateField_management isn't working?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8753#M317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi - I'm having trouble getting an if statement to work and was hoping someone could help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to copy the data from a field called SUM_Green to G, replace any null values in a dataset with 0, so I've used the following, but can't seem to find anything that works:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/281765_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Dec 2016 17:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8753#M317</guid>
      <dc:creator>MichaelRamm</dc:creator>
      <dc:date>2016-12-12T17:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python if statement in arcpy.CalculateField_management isn't working?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8754#M318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just slightly different syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;MULTIs&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"G"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"!SUM_Green! if !SUM_Green! &amp;gt;= 1 else 0"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PYTHON_9.3"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Dec 2016 18:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8754#M318</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-12-12T18:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python if statement in arcpy.CalculateField_management isn't working?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8755#M319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with &lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;‌ that using&amp;nbsp;Python &lt;A href="https://docs.python.org/2/reference/expressions.html#conditional-expressions"&gt;Conditional Expressions &lt;/A&gt;is the way to go in situations like this.&amp;nbsp; In case you couldn't rely on &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;SUM_Green&lt;/SPAN&gt; being greater than or equal to one, you can explicitly handle NULL by using Python's NoneType: &lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CalculateField_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;MULTIs&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"G"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"0 if !SUM_Green! is None else !SUM_Green!"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"PYTHON_9.3"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:42:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8755#M319</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-12-13T01:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python if statement in arcpy.CalculateField_management isn't working?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8756#M320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for both your responses, I've tried Joshua's suggestion and the script has ran through perfectly, just what I needed.&amp;nbsp; Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 11:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-if-statement-in-arcpy-calculatefield/m-p/8756#M320</guid>
      <dc:creator>MichaelRamm</dc:creator>
      <dc:date>2016-12-13T11:13:00Z</dc:date>
    </item>
  </channel>
</rss>

