counting columns with text

1092
12
Jump to solution
03-03-2013 11:26 PM
MiikaMäkelä1
New Contributor
Hi all,

I have 4 columns which can contain a string (a name) or can have a value <NULL>.

I want to create a 5th column where I count the number of strings in the 4 columns.

so for example:

Column A - Column B - Column C - Column D - Column Count

textA - textB - <NULL> - <NULL> - 2
<NULL> - textB - textC - textD - 3

So how do I populate this Column Count?

Thanks for any ideas!

Miika
0 Kudos
12 Replies
MiikaMäkelä1
New Contributor
Thanks!

I couldn't get the first code block to work either, but it was the "less transparent" code that did the job!

Thanks so much, now I won't have to count 700k rows manually 😄
0 Kudos
MiikaMäkelä1
New Contributor
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".
0 Kudos
LT
by
Occasional Contributor
No, I really don't think the None constant was the problem.  I bet it has to do with those special characters in your data.  I don't have any data like that to test, but I do have data with <<Null>> values and it worked fine for that.   My guess is that the special chars in the the strings were stymieing the len function.

Basically, you're just testing if the string is empty or null.  So it could be done as:

if a! = '' and  a =! None:
0 Kudos