<?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: Deleting Empty Fields in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859653#M4151</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What back-end DBMS/datastore holds your data?&amp;nbsp; The support of TRIM and other SQL functions is DBMS/datastore specific.&amp;nbsp; For example, trying to use TRIM in a WHERE clause with file geodatabases will generate a Python RuntimeError due to invalid expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Apr 2019 14:38:29 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-04-24T14:38:29Z</dc:date>
    <item>
      <title>Deleting Empty Fields</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859651#M4149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to find the empty fields in a feature class and delete the fields.i am checking the number of empty or null rows are equal to total number of rows then i am deleting the field.i don't want to go throw all the rows and check field is empty or null.but many fields has spaces in the records i want to trim the spaces in string fields. i could not fingure it how to add trim function in SearchCursor where_clause or in sql_clause. could you please let me know how to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; result &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.GetCount_management(layer)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; totalRows &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; result[&lt;/SPAN&gt;&lt;SPAN style="color: #b5cea8;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; field.type &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;==&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Double'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;query &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'("&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;" is null OR "&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;" = 0)'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.format(&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;field.name)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;query &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'("&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;" is null or "&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"=&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\'\'&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;)'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.format(&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;field.name) #&amp;nbsp;query&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'("&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;" is null or Trim("&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;")=&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\'\'&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;)'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.format(&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;field.name)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; rows &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; [row &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; row &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.da.SearchCursor(layer, [field.name], query)]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;int&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;(totalRows) &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #dcdcaa;"&gt;len&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;(rows):&lt;/SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;arcpy.DeleteField_management(layer, &lt;SPAN style="background-color: #1e1e1e;"&gt;[field.name]&lt;/SPAN&gt;)&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Apr 2019 08:34:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859651#M4149</guid>
      <dc:creator>MichaelLorenz</dc:creator>
      <dc:date>2019-04-24T08:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Empty Fields</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859652#M4150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did that code throw an error?&amp;nbsp; python uses strip() to remove whitespace&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" a "&lt;/SPAN&gt;

a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;'a'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:39:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859652#M4150</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T10:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Empty Fields</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859653#M4151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What back-end DBMS/datastore holds your data?&amp;nbsp; The support of TRIM and other SQL functions is DBMS/datastore specific.&amp;nbsp; For example, trying to use TRIM in a WHERE clause with file geodatabases will generate a Python RuntimeError due to invalid expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Apr 2019 14:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/deleting-empty-fields/m-p/859653#M4151</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-04-24T14:38:29Z</dc:date>
    </item>
  </channel>
</rss>

