<?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: counting columns with text in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73182#M2583</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;SPAN&gt;Yes, it's the character's messing it up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, you could try just reversing ldanzinger's procedure to count null's (he's also counting empty strings--don't know if you want to do that):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def count(a,b,c,d,e):
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(a)) == 0 or str(a) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(b)) == 0 or str(b) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(c)) == 0 or str(c) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(d)) == 0 or str(d) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(e)) == 0 or str(e) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, on second thought this error might just be due to trying to cast a unicode to string. (That is after all the entire point of unicode, that you can encode all those extra characters which an ascii string can't)&amp;nbsp; I don't think there's any need to do that. (Though maybe Lucas knows a reason this must be done.&amp;nbsp; Does PHP need strings, not unicode?&amp;nbsp; But the PHP is only using the count output.&amp;nbsp; So maybe if you still cast that...) Just try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def count(a,b,c,d,e):
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(a) != 0 and a != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(b) != 0 and b != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
... and so forth
&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, Lucas, I am intrigued by your mention of PHP.&amp;nbsp; I've been wondering why the syntax for field calculator statements uses the exclamation points.&amp;nbsp; Can you point me to somewhere I can read more about this?&amp;nbsp; I haven't found any mention of PHP on the field calculator page.&amp;nbsp; --Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:50:36 GMT</pubDate>
    <dc:creator>LT</dc:creator>
    <dc:date>2021-12-10T22:50:36Z</dc:date>
    <item>
      <title>counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73176#M2577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have 4 columns which can contain a string (a name) or can have a value &amp;lt;NULL&amp;gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to create a 5th column where I count the number of strings in the 4 columns.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Column A - Column B - Column C - Column D - Column Count&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;textA - textB - &amp;lt;NULL&amp;gt; - &amp;lt;NULL&amp;gt; - 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;NULL&amp;gt; - textB - textC - textD - 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So how do I populate this Column Count?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any ideas!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Miika&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 07:26:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73176#M2577</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-04T07:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73177#M2578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would use the Calculate Field tool. Use Python as the parser, and set the pre-logic script code to something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[PHP]def count(a, b, c, d):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e= str(a) + str(b) + str(c) + str(d)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return len(e)[/PHP]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The bottom should just be: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[PHP]count(!Field1!, !Field2!, !Field3!, !Field4!)[/PHP]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will feed in these 4 fields to the function, concatenate all of the strings together, then grab the length of the string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 19:09:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73177#M2578</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-04T19:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73178#M2579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Almost - but not quite. Or then I didn't understand it &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached an image what the real situation looks like. There were actually 5 columns that I wanted to count, not 4 - but I don't think that makes much of a difference to the code. But I don't want to count length at any point. I only want the amount of strings (so each column basically has a value of 0 or 1. I tried changing len to count but still couldn't get it to work. Could the NULL values cause problems? There is a lot of them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]22365[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 05:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73178#M2579</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-05T05:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73179#M2580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;note, the image in the previous post - the count column I populated by hand for this example. This is what it should look like.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2013 05:19:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73179#M2580</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-05T05:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73180#M2581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, sorry I didn't understand correctly. Something like this should do the trick:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def count(a,b,c,d,e):
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(a)) != 0 and str(a) != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(b)) != 0 and str(b) != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(c)) != 0 and str(c) != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(d)) != 0 and str(d) != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(e)) != 0 and str(e) != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And the bottom should be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;count( !field1!, !field2!, !field3!, !field4!, !field5!)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:50:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73180#M2581</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2021-12-10T22:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73181#M2582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;this is getting interesting! Thanks a lot for your help so far. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script seems to work basically, but somewhere in the middle of execution it stops in a "failure during processing" message. When I look it up, it refers to error code 539. If I understand correctly the script can't handle the special characters within the names in my fields. The Sami languages have some very strange characters. If this is the problem and we can't figure a solution for it, then a&amp;nbsp; workaround could be to actually count the NULL values. I would arrive to the same figure with an intermediate calculation: 5 - [amount of NULL values] = [amount of names]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you still help me with this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]22393[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 07:00:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73181#M2582</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-06T07:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73182#M2583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;SPAN&gt;Yes, it's the character's messing it up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, you could try just reversing ldanzinger's procedure to count null's (he's also counting empty strings--don't know if you want to do that):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def count(a,b,c,d,e):
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(a)) == 0 or str(a) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(b)) == 0 or str(b) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(c)) == 0 or str(c) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(d)) == 0 or str(d) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(str(e)) == 0 or str(e) == "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, on second thought this error might just be due to trying to cast a unicode to string. (That is after all the entire point of unicode, that you can encode all those extra characters which an ascii string can't)&amp;nbsp; I don't think there's any need to do that. (Though maybe Lucas knows a reason this must be done.&amp;nbsp; Does PHP need strings, not unicode?&amp;nbsp; But the PHP is only using the count output.&amp;nbsp; So maybe if you still cast that...) Just try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def count(a,b,c,d,e):
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(a) != 0 and a != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(b) != 0 and b != "None":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1
... and so forth
&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, Lucas, I am intrigued by your mention of PHP.&amp;nbsp; I've been wondering why the syntax for field calculator statements uses the exclamation points.&amp;nbsp; Can you point me to somewhere I can read more about this?&amp;nbsp; I haven't found any mention of PHP on the field calculator page.&amp;nbsp; --Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:50:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73182#M2583</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2021-12-10T22:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73183#M2584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is harder than I thought!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Reversing the code to count the NULL values doesn't seem to work. Could it be, that you can't count NULL values, because there is nothing to count. I heard of difficulty with these. Maybe I should just select them all and populate 0. Was just hoping to reduce any unnecessary steps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second code block suggestions does however run without any errors. The result just is not correct. It populates NULL for every cell, except for the ones where it does not have to deal with any NULL values - so in this case the rows where there are 5 names in total. So the NULL values override the result. Replacing the NULL values with some other string would possibly help here also, but then the code would have to skip this string. And one more step in the process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all suggestions so far!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 11:38:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73183#M2584</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-11T11:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73184#M2585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about using search cursors instead.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you post a sample dataset?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 13:11:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73184#M2585</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2013-03-11T13:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73185#M2586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Nevermind about the data.&amp;nbsp; I found some of my own that has Nulls...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def count(a,b,c,d,e): &amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp; if len(a) != 0 and a != None: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1 &amp;nbsp;&amp;nbsp;&amp;nbsp; if len(b) != 0 and b != None: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1 ... and so forth &amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;None is a built-in Python constant.&amp;nbsp; Not a string spelled 'None'.&amp;nbsp; You have to check against the constant.&amp;nbsp; In fact, a much more sleek (though less transparent) solution would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def count(a,b,c,d,e): &amp;nbsp;&amp;nbsp;&amp;nbsp; x = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp; if a: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1 &amp;nbsp;&amp;nbsp;&amp;nbsp; if b: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x +=1 ... and so forth &amp;nbsp;&amp;nbsp;&amp;nbsp; return str(x)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 13:27:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73185#M2586</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2013-03-11T13:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73186#M2587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I couldn't get the first code block to work either, but it was the "less transparent" code that did the job!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much, now I won't have to count 700k rows manually &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 06:45:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73186#M2587</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-12T06:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73187#M2588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So, maybe the problem is something with this none constant in Python? I'm using ArcGIS 10.1 - could there be differences in Python coding? Anyway, the problem is solved with the "less transparent code".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 06:50:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73187#M2588</guid>
      <dc:creator>MiikaMäkelä1</dc:creator>
      <dc:date>2013-03-12T06:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: counting columns with text</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73188#M2589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, I really don't think the None constant was the problem.&amp;nbsp; I bet it has to do with those special characters in your data.&amp;nbsp; I don't have any data like that to test, but I do have data with &amp;lt;&amp;lt;Null&amp;gt;&amp;gt; values and it worked fine for that.&amp;nbsp;&amp;nbsp; My guess is that the special chars in the the strings were stymieing the len function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically, you're just testing if the string is empty or null.&amp;nbsp; So it could be done as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if a! = '' and&amp;nbsp; a =! None:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 19:44:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counting-columns-with-text/m-p/73188#M2589</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2013-03-15T19:44:47Z</dc:date>
    </item>
  </channel>
</rss>

