<?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 Field Calculator Null Values in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100861#M2687</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just ran into this now. While I think I understand your solution, this seems like an odd behavior for the design of the Field Calculator. I would consider it a bug. Perhaps someone at ESRI can explain the reasoning for this behavior?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 May 2011 03:24:05 GMT</pubDate>
    <dc:creator>DavidStrip</dc:creator>
    <dc:date>2011-05-16T03:24:05Z</dc:date>
    <item>
      <title>Python Field Calculator Null Values</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100859#M2685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to calculate the value of a field based on multiple other fields. My code works fine in Python, but it bombs in ArcPad. The reason must be that I have Null values in a lot of my fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a very simplified illustration:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def main (a,b):
&amp;nbsp; return a&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;field1 = &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt; main(1, !field2!)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where !field2! is a field that is Null&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I receive no error, it just won't place the calculated "1" into field2. If you were to put:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;field1 = &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;main(1,2)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;field1 = &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;main(!field3!, !field4!)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;with field3 and field4 holding a non null value, the calculator works as expected. I can't even test for Nulls b/c Python in the Field Calculator apparantly doesn't allow you to access the fields directly in the Codeblock like VBScript would.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone else ran into this? This seems like it would be a fairly common issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Feb 2011 23:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100859#M2685</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2011-02-15T23:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python Field Calculator Null Values</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100860#M2686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok... can't believe nobody else has ran into this, but....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found not to use the FieldCalculator. Just create your own updateCursor. Make sure to include &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;from types import *&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then just test by&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if type(c.field) is not NoneType:&lt;/PRE&gt;&lt;SPAN&gt; Then, if you want to return a Null value: &lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;c.field = None&lt;/PRE&gt;&lt;SPAN&gt; All of this where c is your updateCursor and field is the field you are testing and setting.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2011 19:53:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100860#M2686</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2011-03-01T19:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python Field Calculator Null Values</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100861#M2687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just ran into this now. While I think I understand your solution, this seems like an odd behavior for the design of the Field Calculator. I would consider it a bug. Perhaps someone at ESRI can explain the reasoning for this behavior?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 03:24:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100861#M2687</guid>
      <dc:creator>DavidStrip</dc:creator>
      <dc:date>2011-05-16T03:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Python Field Calculator Null Values</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100862#M2688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Isn't it this behavior?&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;Seems to be fixed in 10.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 12:40:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100862#M2688</guid>
      <dc:creator>ZdeněkJankovský</dc:creator>
      <dc:date>2012-02-02T12:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python Field Calculator Null Values</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100863#M2689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I'm on 10 SP3 and it seems to be fixed&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Isn't it this behavior?&lt;BR /&gt;&lt;BR /&gt;NIM059424 - Null values in the feature class do not get replaced when using Python in the Field Calculator.&lt;BR /&gt;&lt;BR /&gt;Seems to be fixed in 10.1.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't really use python with the field Calculator anymore, though. I had to switch to using cursors to get around the issue and haven't looked back. If you're going to go through all the trouble to create some code, might as well do it up right.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2012 15:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-field-calculator-null-values/m-p/100863#M2689</guid>
      <dc:creator>JasonTipton</dc:creator>
      <dc:date>2012-02-22T15:31:56Z</dc:date>
    </item>
  </channel>
</rss>

