<?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: Function to delete records  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105618#M8117</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Liana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look at this thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/55714"&gt;Delete Rows where value is Null&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe this will have the solution that you need. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 May 2016 17:51:36 GMT</pubDate>
    <dc:creator>AdrianWelsh</dc:creator>
    <dc:date>2016-05-19T17:51:36Z</dc:date>
    <item>
      <title>Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105617#M8116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need a small code in python that will delete records that have empty value in a specific field of the layer. The name of the feature class is WCSCustomer and the name of the field is GROUTE&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 17:45:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105617#M8116</guid>
      <dc:creator>LianaSmith</dc:creator>
      <dc:date>2016-05-19T17:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105618#M8117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Liana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look at this thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/55714"&gt;Delete Rows where value is Null&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe this will have the solution that you need. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 17:51:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105618#M8117</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-05-19T17:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105619#M8118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Adrian. I have just empty value, not Null.. I am not sure if I can change the script for that myself..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 17:55:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105619#M8118</guid>
      <dc:creator>LianaSmith</dc:creator>
      <dc:date>2016-05-19T17:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105620#M8119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;maybe try&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

fc = r'C:\tmp\Test.gdb\WCSCustomer'
field = "GROUTE"
whereClause = field + ' = ""'

updCurs = arcpy.UpdateCursor(fc, 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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105620#M8119</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2021-12-11T06:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105621#M8120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use None instead of "Null"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for x in this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if x is None:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete that stuff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 17:58:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105621#M8120</guid>
      <dc:creator>MitchHolley1</dc:creator>
      <dc:date>2016-05-19T17:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105622#M8121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adrian,&lt;/P&gt;&lt;P&gt;I tried to ran it and I get an exception..&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/201502_pastedImage_0.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 18:16:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105622#M8121</guid>
      <dc:creator>LianaSmith</dc:creator>
      <dc:date>2016-05-19T18:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105623#M8122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yeah, an issue with the SQL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since it's in a file geodatabase, could you just use the Null value approach?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy


fc = r"C:\tmp\Test.gdb\WCSCustomer"
field = "GROUTE"
whereClause = field + " IS NULL"


updCurs = arcpy.UpdateCursor(fc, 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;P&gt;&lt;/P&gt;&lt;P&gt;Or use Mitch's example of if x is none, etc....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:26:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105623#M8122</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2021-12-11T06:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105624#M8123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or alternately&lt;/P&gt;&lt;P&gt;do the row.getvalue or row[index number] thing ( we will call it x using Mitch's designation)&lt;/P&gt;&lt;P&gt;then....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if x in [None,""]:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete stuff&lt;/P&gt;&lt;P&gt;The rationale is that an empty records is going to show &amp;lt;null&amp;gt; in the table, but python returns None and shapefiles store "" and other stuff stores one of those two (if memory serves).&amp;nbsp; The nice thing is you can add anything you want to the list.&amp;nbsp; the python 'isinstance' can also be used, but then you have to remember the class and None is a NoneType or which there is only one instance of that class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 20:13:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105624#M8123</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-19T20:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105625#M8124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this whole thread I don't see the full example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code will zap the row if the field contents is spaces, empty string, or Null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc = r"C:\tmp\Test.gdb\WCSCustomer"
field = "GROUTE"
with arcpy.da.UpdateCursor(fc, field) as rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = row[0].strip()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = row[0]
&lt;SPAN style="font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if val in ["", None]:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.deleteRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:26:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105625#M8124</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T06:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105626#M8125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume you are working with text fields since you are talking about empty being different than Null (or None in Python).&amp;nbsp; When working with text fields, just be aware there are some characters and numerous control characters that don't display (the field will look empty in ArcMap/ArcCatalog) but prevent &lt;SPAN style="font-family: courier new,courier;"&gt;!field! == ""&lt;/SPAN&gt; from being &lt;SPAN style="font-family: courier new,courier;"&gt;True&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might be worth looking over the following discussion:&amp;nbsp; &lt;A href="https://community.esri.com/message/606157"&gt;I am trying to calculate a field where i want to exclude any null values. For example. Field calulate field X with any value that is not null from field Y. I have been messing with python, but just can not seem to get this to run properly.&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 21:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105626#M8125</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-05-20T21:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105627#M8126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found code to &lt;A href="http://stackoverflow.com/a/1342373/2234229" rel="nofollow noopener noreferrer" target="_blank"&gt;strip all non printables &lt;/A&gt;on StackOverflow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def stripper(s):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "".join(i for i in s if ord(i)&amp;lt;127 and ord(i)&amp;gt;32)

fc = r"C:\tmp\Test.gdb\WCSCustomer" 
field = "GROUTE" 
with arcpy.da.UpdateCursor(fc, field) as rows: 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = stripper(s)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = row[0] 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if val in ["", None]: 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.deleteRow(row) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:26:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105627#M8126</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T06:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Function to delete records</title>
      <link>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105628#M8127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;with the unicode encoding cavaet is people move closer to python 3.&amp;nbsp; Make sure you read that full thread, it is interesting... a "space" is much like "nothing"..it comes in many forms&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 May 2016 03:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/function-to-delete-records/m-p/105628#M8127</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-22T03:03:44Z</dc:date>
    </item>
  </channel>
</rss>

