<?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 Check if a field in a feature class is totally empty to delete it? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254734#M66783</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to delete all empty fields in a feature class (arcgis pro 3.0 - notebooks) - with no sucess. The following script doesn't work, it prints fields as count = 0 which have valid attributes.&lt;/P&gt;&lt;P&gt;Any better ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc = "Merge_1"

fields = [f.name for f in arcpy.ListFields(fc) if not f.required]

for field in fields:
    count = 0
    with arcpy.da.SearchCursor(fc, field) as cursor:
        for row in cursor:
            
            if row[0] is None or row[0] in ["", " ", "0"]:
                count += 0
            else:
                count += 1
                break
                
    print(field, count)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 05:37:38 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2023-02-03T05:37:38Z</dc:date>
    <item>
      <title>Check if a field in a feature class is totally empty to delete it?</title>
      <link>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254734#M66783</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to delete all empty fields in a feature class (arcgis pro 3.0 - notebooks) - with no sucess. The following script doesn't work, it prints fields as count = 0 which have valid attributes.&lt;/P&gt;&lt;P&gt;Any better ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc = "Merge_1"

fields = [f.name for f in arcpy.ListFields(fc) if not f.required]

for field in fields:
    count = 0
    with arcpy.da.SearchCursor(fc, field) as cursor:
        for row in cursor:
            
            if row[0] is None or row[0] in ["", " ", "0"]:
                count += 0
            else:
                count += 1
                break
                
    print(field, count)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 05:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254734#M66783</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2023-02-03T05:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a field in a feature class is totally empty to delete it?</title>
      <link>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254736#M66784</link>
      <description>&lt;P&gt;Sorry it works sucessfully ...&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 05:58:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254736#M66784</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2023-02-03T05:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a field in a feature class is totally empty to delete it?</title>
      <link>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254767#M66785</link>
      <description>&lt;P&gt;since you have run it against something to compare to, what does this return&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/field-statistics-to-table.htm" target="_blank"&gt;Field Statistics To Table (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;wondering what is returned if All types and the options for&amp;nbsp; nulls, count and unique&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 09:23:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254767#M66785</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-02-03T09:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a field in a feature class is totally empty to delete it?</title>
      <link>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254776#M66786</link>
      <description>&lt;P&gt;Didn't knowed this tool, if I run it with one empty field I want to delete I get something like this:&lt;/P&gt;&lt;P&gt;Sorry it's in german ...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesBierer_0-1675417150681.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/62025i5DC894F1B776B657/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesBierer_0-1675417150681.png" alt="JohannesBierer_0-1675417150681.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I think the problem with this tool will be that it's some kind of chaotic data merge out of excel files in the fc. The fields to delete could contain&amp;nbsp; Null values, "", "0", " " ... .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 09:46:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254776#M66786</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2023-02-03T09:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a field in a feature class is totally empty to delete it?</title>
      <link>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254786#M66787</link>
      <description>&lt;P&gt;That is a problem.&amp;nbsp; People should really set up Excel's "Data Validation" for their spreadsheet columns if they are using Excel for data entry or acquisition.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 10:12:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/check-if-a-field-in-a-feature-class-is-totally/m-p/1254786#M66787</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-02-03T10:12:09Z</dc:date>
    </item>
  </channel>
</rss>

