<?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: Testing for empty fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211380#M16328</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;By &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"records without values"&lt;/SPAN&gt;&lt;SPAN&gt; do you mean records with NULL or records with just an empty string? If a string is empty it will have length zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this should do the trick:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;"if not allowed and not none and not an empty string"&lt;/SPAN&gt;&lt;SPAN&gt; (well, maybe you don't have to worry about the None, so you can delete that perhaps)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if (suffval not in allowed) &amp;amp; (suffval is not None) &amp;amp; (len(suffval) != 0):&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Sep 2011 22:04:10 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2011-09-05T22:04:10Z</dc:date>
    <item>
      <title>Testing for empty fields</title>
      <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211379#M16327</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;SPAN&gt;I have a Python script which flags records with inappropriate values.&amp;nbsp; Unfortunately, it is also flagging records without values.&amp;nbsp; I would like to know how I can check for the existence of a value in a field.&amp;nbsp; Normally, if there is a value in this field, it would be a string.&amp;nbsp; Here's what I have currently:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if (suffval != '') and (suffval not in allowed):&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;the first condition is the one I'm having trouble with - the second condition seems to work fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have also tried:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if (suffval is not None)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if (not len(suffval))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much for any guidance you can provide.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 21:48:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211379#M16327</guid>
      <dc:creator>LeighHolcombe</dc:creator>
      <dc:date>2011-09-05T21:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Testing for empty fields</title>
      <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211380#M16328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;By &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"records without values"&lt;/SPAN&gt;&lt;SPAN&gt; do you mean records with NULL or records with just an empty string? If a string is empty it will have length zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this should do the trick:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;"if not allowed and not none and not an empty string"&lt;/SPAN&gt;&lt;SPAN&gt; (well, maybe you don't have to worry about the None, so you can delete that perhaps)&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if (suffval not in allowed) &amp;amp; (suffval is not None) &amp;amp; (len(suffval) != 0):&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 22:04:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211380#M16328</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-09-05T22:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Testing for empty fields</title>
      <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211381#M16329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;By &lt;SPAN style="font-style:italic;"&gt;"records without values"&lt;/SPAN&gt; do you mean records with NULL or records with just an empty string? If a string is empty it will have length zero.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume the fields in question are NULL.&amp;nbsp; I'm working with a street database, and this particular field is the directional suffix, which not every street requires.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 22:13:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211381#M16329</guid>
      <dc:creator>LeighHolcombe</dc:creator>
      <dc:date>2011-09-05T22:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Testing for empty fields</title>
      <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211382#M16330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Arc NULL is None in Python. So&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (suffval not in allowed) &amp;amp; (suffval is not None) &amp;amp; (len(suffval) != 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp; # flag record&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;will flag records where the suffval is not allowed, not NULL (None) and not empty string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:24:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211382#M16330</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T10:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Testing for empty fields</title>
      <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211383#M16331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When your suggested code didn't work, I prayed something else was wrong.&amp;nbsp; Sure enough, instead of using NULLs or empty strings, my working database used a whitespace character.&amp;nbsp; The following code produced the intended results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if (suffval != ' ') and (suffval not in allowed)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;(that's a space between the single quotes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your guidance, problem solved.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 02:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211383#M16331</guid>
      <dc:creator>LeighHolcombe</dc:creator>
      <dc:date>2011-09-06T02:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Testing for empty fields</title>
      <link>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211384#M16332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sweet, another handy one is &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;isspace&lt;/SPAN&gt;&lt;SPAN&gt;, which will pick up multiple spaces as well (your current code will only pick up one space). I.e.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if (not suffval.isspace()) and (suffval not in allowed):&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 02:37:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/testing-for-empty-fields/m-p/211384#M16332</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-09-06T02:37:58Z</dc:date>
    </item>
  </channel>
</rss>

