<?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 Use update cursor to find empty fields in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29516#M1060</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I used the 'Merge' tool to combine two feature classes (call them FC1 and FC2), and the resulting feature class (FC3) was put into a file geodatabase.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then added new fields to FC3.&amp;nbsp; I want to be able to populate the newly added fields by copying the values from fields that were carried over from FC1 and FC2, and then eventually delete the old fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to create a script that will use an update cursor to look at each row, and if there's a value for field1, then it would copy it to field3.&amp;nbsp; If there's no value (aka it's null), then it would copy field2 to field3.&amp;nbsp; However, the script doesn't recognize when there's a null value, and therefore it always copies from field1, even if it's an empty cell (there's never an instance where both field1 and field2 are empty).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 != "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.field3 = row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.field3 = row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del rows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I was testing it out, I modified the code (below) to see what arcpy is seeing, and when there were null values, it returned "None" as the value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 != "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del rows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried fixing it by changing the code to &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if row.field1 != "None":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but it didn't change anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&amp;nbsp; What am I doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Jan 2011 22:02:30 GMT</pubDate>
    <dc:creator>ChristinaHerrick1</dc:creator>
    <dc:date>2011-01-12T22:02:30Z</dc:date>
    <item>
      <title>Use update cursor to find empty fields</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29516#M1060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I used the 'Merge' tool to combine two feature classes (call them FC1 and FC2), and the resulting feature class (FC3) was put into a file geodatabase.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then added new fields to FC3.&amp;nbsp; I want to be able to populate the newly added fields by copying the values from fields that were carried over from FC1 and FC2, and then eventually delete the old fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to create a script that will use an update cursor to look at each row, and if there's a value for field1, then it would copy it to field3.&amp;nbsp; If there's no value (aka it's null), then it would copy field2 to field3.&amp;nbsp; However, the script doesn't recognize when there's a null value, and therefore it always copies from field1, even if it's an empty cell (there's never an instance where both field1 and field2 are empty).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 != "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.field3 = row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.field3 = row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del rows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I was testing it out, I modified the code (below) to see what arcpy is seeing, and when there were null values, it returned "None" as the value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 != "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del rows&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried fixing it by changing the code to &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if row.field1 != "None":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but it didn't change anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&amp;nbsp; What am I doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2011 22:02:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29516#M1060</guid>
      <dc:creator>ChristinaHerrick1</dc:creator>
      <dc:date>2011-01-12T22:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use update cursor to find empty fields</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29517#M1061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No quotes on the None:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if row.field1 != None:&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or better (grab empty string AND null values):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if row.field1:&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I used the 'Merge' tool to combine two feature classes (call them FC1 and FC2), and the resulting feature class (FC3) was put into a file geodatabase.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;I then added new fields to FC3.&amp;nbsp; I want to be able to populate the newly added fields by copying the values from fields that were carried over from FC1 and FC2, and then eventually delete the old fields.&lt;BR /&gt;&lt;BR /&gt;I am trying to create a script that will use an update cursor to look at each row, and if there's a value for field1, then it would copy it to field3.&amp;nbsp; If there's no value (aka it's null), then it would copy field2 to field3.&amp;nbsp; However, the script doesn't recognize when there's a null value, and therefore it always copies from field1, even if it's an empty cell (there's never an instance where both field1 and field2 are empty).&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 != "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.field3 = row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.field3 = row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;When I was testing it out, I modified the code (below) to see what arcpy is seeing, and when there were null values, it returned "None" as the value.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;desc = arcpy.Describe(fc3)
fields = desc.fields
rows = arcpy.UpdateCursor(fc3)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.field1 != "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.field1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.field2
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I tried fixing it by changing the code to &lt;BR /&gt;if row.field1 != "None":&lt;BR /&gt;but it didn't change anything.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&amp;nbsp; What am I doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:11:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29517#M1061</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-10T21:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Use update cursor to find empty fields</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29518#M1062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the speedy reply!&amp;nbsp; The first suggestion worked just fine&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;row.field1 != None&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the second suggestion didn't work.&amp;nbsp; When I tried it, nothing happened.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jan 2011 00:24:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29518#M1062</guid>
      <dc:creator>ChristinaHerrick1</dc:creator>
      <dc:date>2011-01-13T00:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Use update cursor to find empty fields</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29519#M1063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Whoops, meant to put a not in there like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if not row.field1:&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;glad it works.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jan 2011 00:39:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-update-cursor-to-find-empty-fields/m-p/29519#M1063</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-01-13T00:39:54Z</dc:date>
    </item>
  </channel>
</rss>

