I have a bunch of fields, some populated with data, some not, that I need to concatenate. How can I concatenate while excluding the null values?

3048
10
Jump to solution
03-17-2022 05:16 AM
MatthewBeal
Occasional Contributor III

Here is an example of the fields I need to concatenate:

 

MatthewBeal_0-1647519290685.png

 

In this case only Street Name and Post Type are populated. But in other cases, all of those fields could contain street name components that need to be concatenated. Is there an easy way to concatenate only the fields that are not <Null>?

Tags (2)
0 Kudos
10 Replies
KimHazelwood
New Contributor II

I found a better solution, using the strip() command   don't need the if statement

using replace at the ends gets rid of the None

(str( !PRE_DIR!).strip()+' '+str(!PLAINST!).strip()+' '+str(!SUF_DIR!).strip()+' '+str(!STREETTYPE!).strip()).replace('None','').strip()

0 Kudos