Select to view content in your preferred language

I have a bunch of non-nullable fields that I need to concatenate, but my usual process is returning weird spaces.

293
2
Jump to solution
10-10-2024 06:26 AM
FionaHayward
New Contributor

I am trying to concatenate a group of fields, but there are some non-nullable entries that contain a single space.

This is an example of the setup I made in excel, and example results are in the "RESULT" field.  The results I want but can't figure out are in the "DESIRED RESULT" field.  Basically just to remove all the weird spaces put in by the non-nullable fields.

FionaHayward_0-1728566457738.png

I am currently trying this code:

" ".join([str(i) for i in [ !STREET_NUM!, !PREDIR!, !PRETYPE!, !NAME!,!TYPE!, !SUFDIR!, !UNIT_TYPE!, !UNIT_NUM!] if i])

 

However, I think it is picking up the spaces as filled boxes within the program and spitting them out as double spaces in the final result.  I can't figure out how to resolve this so it gives me the desired result.

It's also not an option to nullify those fields.

 

Any ideas?  Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @FionaHayward,

My hunch is that there is either a space in one of the values in the list of values or there is a trailing space at the end of one of the non-empty values.

Try going through and using the <string_value>.strip() method to remove any spaces.

View solution in original post

2 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @FionaHayward,

My hunch is that there is either a space in one of the values in the list of values or there is a trailing space at the end of one of the non-empty values.

Try going through and using the <string_value>.strip() method to remove any spaces.

FionaHayward
New Contributor

This worked!  Thank you!!

0 Kudos