<?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: Test for Null values Field Calculator in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357708#M28227</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That is odd, it works for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Sorry no, I was using a cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(layer)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; var = row.AREAESTIMATED
&amp;nbsp;&amp;nbsp;&amp;nbsp; if var:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.TAG = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.TAG = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:43:07 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2021-12-11T16:43:07Z</dc:date>
    <item>
      <title>Test for Null values Field Calculator</title>
      <link>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357705#M28224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I just finished reading a bunch of threads on this, but need to double check this issue.&amp;nbsp; I want to put something like this &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
def i(x):
&amp;nbsp; if x is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Used to be Null"
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return x
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;into the code-block, but I've tried all sorts of variations that have been suggested, x == None, x == "", if not x, but nothing has produced any change in the values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I missing something, or is this just not going to work and I'll have to use update cursors to perform operations like this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using 10.0 SP5.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Feb 2013 20:29:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357705#M28224</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2013-02-07T20:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Test for Null values Field Calculator</title>
      <link>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357706#M28225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;May be a bug, there were a lot of issues with null values in 10.0 I believe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NIM079575 - Field Calculator does not recognize &amp;lt;Null&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NIM059424 - Null values in the feature class do not get replaced when using Python in the Field Calculator. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NIM086737 - The Select by Attributes tool using "IS NULL" on a joined field does not return selections in ArcGIS 10 SP5.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NIM063379 - A Field Calculator error dialog opens in PythonWin for an assignment of a null value to a text field in a shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe this was the work around.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def i(x):
&amp;nbsp;&amp;nbsp;&amp;nbsp; var = x
&amp;nbsp;&amp;nbsp;&amp;nbsp; if var:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Used to be Null"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return var&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:43:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357706#M28225</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T16:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Test for Null values Field Calculator</title>
      <link>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357707#M28226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello and thanks for the reply,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, that work around still produces nothing.&amp;nbsp; I happened to be working with a joined table, but after removing the join, still no luck.&amp;nbsp; It doesn't even work to flip it around and say&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
def i(x):
&amp;nbsp; var = x
&amp;nbsp; if var:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return var
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "not null anymore"
&lt;/PRE&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Because I'm starting with all Null values, I think my first step will just be to write "NULL" to the entire field, which works, and then query against the string "NULL".&amp;nbsp; Any other ideas would be welcome, too, of course.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:43:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357707#M28226</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T16:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Test for Null values Field Calculator</title>
      <link>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357708#M28227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That is odd, it works for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Sorry no, I was using a cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(layer)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; var = row.AREAESTIMATED
&amp;nbsp;&amp;nbsp;&amp;nbsp; if var:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.TAG = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.TAG = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:43:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357708#M28227</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T16:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Test for Null values Field Calculator</title>
      <link>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357709#M28228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I also have had this problem, ultimately I gave up on the field calculator and made a stand alone python program to to the job.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

arcpy.env.workspace = "Z:\myTest.gdb" #path to your geodatabase

rows = arcpy.UpdateCursor("test") #test is the name of the feature class you wish to work with 


for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.test1 == None: #test1 would be the name of the field in the feature calss 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.test1 = "Used to be Null"

&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del row
del rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/test-for-null-values-field-calculator/m-p/357709#M28228</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2021-12-11T16:43:10Z</dc:date>
    </item>
  </channel>
</rss>

