<?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: How do I check if a field in the attribute table contains a blank cell? in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239040#M44332</link>
    <description>&lt;P&gt;What's the database type and version?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[&lt;STRONG&gt;Edit:&lt;/STRONG&gt; That's relevant for possible SQL solutions. I posted this thinking I was the first person to reply. Meanwhile, Johannes had already posted a solution in the background without me realizing it.]&lt;/EM&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;For Oracle, here's a related PL/SQL post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-enterprise-questions/oracle-egdb-find-junk-values-in-all-tables-and/td-p/1239037" target="_self"&gt;Oracle EGDB: Find junk values in all tables and columns (and log them in a table)&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Dec 2022 08:32:59 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2022-12-08T08:32:59Z</dc:date>
    <item>
      <title>How do I check if a field in the attribute table contains a blank cell?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239028#M44329</link>
      <description>&lt;P&gt;&lt;STRONG&gt;I have a number of layers, and each layer contains a large number of data, and I want to know is there any empty cell in the layers attribute table without opening and previewing those tables?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 07:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239028#M44329</guid>
      <dc:creator>AhmedWaheed1</dc:creator>
      <dc:date>2022-12-08T07:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I check if a field in the attribute table contains a blank cell?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239031#M44331</link>
      <description>&lt;P&gt;Just start up a SearchCursor for each layer / table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def check_for_null_values(layer_or_table):
    fields = [f.name for f in  arcpy.ListFields(layer_or_table)]
    sql = " OR ".join([f"{field} IS NULL" for field in fields])
    num_rows = 0
    empty_fields = []
    with arcpy.da.SearchCursor(layer_or_table, fields, sql) as cursor:
        for row in cursor:
            num_rows += 1
            for i, value in enumerate(row):
                if value is None:
                    empty_fields.append(fields[i])
    empty_fields = sorted(set(empty_fields))
    return (num_rows, empty_fields)



layers = ["TestPoints", "TestLines", "TestPolygons", "TestTable"]
for layer in layers:
    result = check_for_null_values(layer)
    print(f"{layer} contains {result[0]} rows with null values. Fields: {', '.join(result[1])}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TestPoints contains 3 rows with null values. Fields: DISTANCE, DateField, DateField2, #...
TestLines contains 0 rows with null values. Fields: 
TestPolygons contains 1 rows with null values. Fields: IntegerField
TestTable contains 71 rows with null values. Fields: DateField, DateField2, #...&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2022 07:41:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239031#M44331</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-08T07:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I check if a field in the attribute table contains a blank cell?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239040#M44332</link>
      <description>&lt;P&gt;What's the database type and version?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;[&lt;STRONG&gt;Edit:&lt;/STRONG&gt; That's relevant for possible SQL solutions. I posted this thinking I was the first person to reply. Meanwhile, Johannes had already posted a solution in the background without me realizing it.]&lt;/EM&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;For Oracle, here's a related PL/SQL post:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-enterprise-questions/oracle-egdb-find-junk-values-in-all-tables-and/td-p/1239037" target="_self"&gt;Oracle EGDB: Find junk values in all tables and columns (and log them in a table)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 08:32:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239040#M44332</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-12-08T08:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I check if a field in the attribute table contains a blank cell?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239041#M44333</link>
      <description>&lt;P&gt;It should be completely independent from the dbms and version, as arcpy handles all the interfacing with the database.&lt;/P&gt;&lt;P&gt;Working on your question right now.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 08:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239041#M44333</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-08T08:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I check if a field in the attribute table contains a blank cell?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239060#M44334</link>
      <description>&lt;P data-unlink="true"&gt;Alternatively, you can also take the script I posted in&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/351335"&gt;@Bud&lt;/a&gt;&amp;nbsp;'s &lt;A href="https://community.esri.com/t5/arcgis-enterprise-questions/oracle-egdb-find-junk-values-in-all-tables-and/m-p/1239049/highlight/true#M34761" target="_blank" rel="noopener"&gt;question&lt;/A&gt;&amp;nbsp;&amp;nbsp;and replace the junk_values list:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def check_for_junk_values(layer_or_table):
    fields = [f.name for f in  arcpy.ListFields(layer_or_table)]
    junk_values = [None]
    data = [dict(zip(fields, row)) for row in arcpy.da.SearchCursor(layer_or_table, fields)]  # [{"Field1": 0, "Field2": 1}, {"Field1": 5, "Field2": 2}]
    counts = dict()
    for row in data:
        for field, value in row.items():
            if value in junk_values:
                key = (field, value)
                try:
                    counts[key] += 1
                except KeyError:
                    counts[key] = 1
    return counts



tables = ["TestPoints", "TestLines", "TestPolygons", "TestTable"]
# you can also use paths to your tables, or list them automatically with arcpy.ListTables() / arcpy.ListFeatureclasses()

log_table = arcpy.management.CreateTable("memory", "JunkLogTable")
arcpy.management.AddField(log_table, "TABLE_NAME", "TEXT")
arcpy.management.AddField(log_table, "COLUMN_NAME", "TEXT")
arcpy.management.AddField(log_table, "VAL_COUNT", "SHORT")
arcpy.management.AddField(log_table, "VALUE", "TEXT")

with arcpy.da.InsertCursor(log_table, ["TABLE_NAME", "COLUMN_NAME", "VALUE", "VAL_COUNT"]) as cursor:
    for table in tables:
        result = check_for_junk_values(table)
        for key, count in result.items():
            col = key[0]
            val = key[1].__repr__()  # __repr__() to get the quotes
            cursor.insertRow([table, col, val, count])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This results in a log table which lists the found fields more precisely:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1670490978576.png" style="width: 507px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/57937i6052D473F5743721/image-dimensions/507x326?v=v2" width="507" height="326" role="button" title="JohannesLindner_0-1670490978576.png" alt="JohannesLindner_0-1670490978576.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 09:17:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239060#M44334</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-08T09:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I check if a field in the attribute table contains a blank cell?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239139#M44335</link>
      <description>&lt;P&gt;If you're using ArcGIS Pro you can also use the data engineering tools to analyze the contents of your table. On of the statistics they could for fields is how many null values there are:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/data-engineering/view-statistics.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/data-engineering/view-statistics.htm&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 14:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-do-i-check-if-a-field-in-the-attribute-table/m-p/1239139#M44335</guid>
      <dc:creator>RobertKrisher</dc:creator>
      <dc:date>2022-12-08T14:29:33Z</dc:date>
    </item>
  </channel>
</rss>

