<?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 Delete Rows where value is Null in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75054#M6120</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a table in a geodatabase where the value of a field is sometimes &amp;lt;Null&amp;gt;. How can I delete these rows?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Karsten&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jul 2012 18:54:23 GMT</pubDate>
    <dc:creator>KarstenRank</dc:creator>
    <dc:date>2012-07-19T18:54:23Z</dc:date>
    <item>
      <title>Delete Rows where value is Null</title>
      <link>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75054#M6120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a table in a geodatabase where the value of a field is sometimes &amp;lt;Null&amp;gt;. How can I delete these rows?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Karsten&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2012 18:54:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75054#M6120</guid>
      <dc:creator>KarstenRank</dc:creator>
      <dc:date>2012-07-19T18:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Rows where value is Null</title>
      <link>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75055#M6121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Off the top of my head I can think of two ways.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Option 1: Cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;up_curs = arcpy.UpdateCursor(fc,"FIELD IS NULL")
for row in up_curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not row.getValue(FIELD):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.deleteRow(row)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Option 2: Select/Delete Features&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.MakeFeatureLayer_management(fc,layer)
arcpy.SelectLayerByAttribute_management(layer,"FIELD IS NULL")
desc = arcpy.Describe(layer)

feat_count = int(arcpy.GetCount_management(parcel).getOutput(0))
feat_ids = desc.FIDSet

if feat_count &amp;gt; 0 and len(feat_ids) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteFeatures_management(layer)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: I haven't tested either of these so make sure you do some trials in a test environment.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:54:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75055#M6121</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-10T22:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Rows where value is Null</title>
      <link>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75056#M6122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I insert the field name "Liste", I get the error message &amp;lt;type 'exceptions.NameError'&amp;gt;: name 'Liste' is not defined.[ATTACH=CONFIG]16269[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;up_curs = arcpy.UpdateCursor(EingabeTabelle,"Liste IS NULL")
for row in up_curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not row.getValue(Liste):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.deleteRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75056#M6122</guid>
      <dc:creator>KarstenRank</dc:creator>
      <dc:date>2021-12-10T22:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Rows where value is Null</title>
      <link>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75057#M6123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have to provide valid SQL where clause and defined variable in &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;getValue()&lt;/SPAN&gt;&lt;SPAN&gt; function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy EingabeTabelle = r"C:\tmp\Test.gdb\YourTable" field = "Liste" whereClause = field + " IS NULL"&amp;nbsp; updCurs = arcpy.UpdateCursor(EingabeTabelle, whereClause) for row in updCurs: &amp;nbsp;&amp;nbsp;&amp;nbsp; if not row.getValue(field): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updCurs.deleteRow(row)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jul 2012 07:15:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75057#M6123</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-07-20T07:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Rows where value is Null</title>
      <link>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75058#M6124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! This&amp;nbsp; solved my probl&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Karsten&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jul 2012 16:00:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-rows-where-value-is-null/m-p/75058#M6124</guid>
      <dc:creator>KarstenRank</dc:creator>
      <dc:date>2012-07-22T16:00:11Z</dc:date>
    </item>
  </channel>
</rss>

