I have some addressing data that I would like to update and one of the tasks is to concatenate a new full street address field [ADDR1] by combining several of the component fields. I know how to do this in VBScript, but figured this would be a good example to work out in Python, as I don't use Python often and have alot to learn. My programming background is FORTRAN and BASIC, and in the years since those were popular hack and slash adapting code for AML/Avenue/VBA/VB.Net - so assume I know little about Python.
What is desired (psuedo-logic):
ADDR1 = STRNUM + STRNUMSUF + STRPREDIR + STRNAME + STRTYPE + STRSUFDIR
I'm using ArcGIS 10.2.1 and the data shown here is test data in a File Geodatabase feature class.
After poking around various Help articles, it appears that in Python the .format method in would work. However, when I run it in Field Calculator the result looks good except "None" gets concatenated as text if the original field value was NULL (this issue doesn't come up with VBScript). I'd like any values of NULL to instead just be blank - i.e. ignore them entirely. For example, for the first record the desired outcome in ADDR1 is "224 D N CHURCH ST" not "224 D N CHURCH ST None".
One of the Python articles I found mentions the NULL issue:
Source: Concatenating field values using Calculate Field | ArcGIS Blog
Is there a different way to do the concatenation in Python to achieve the desired outcome? I'm trying to wrap my head around how Python approaches this, particularly in regards to using it in ArcMap in Field Calculator.
Lastly, can you recommend a good guide for beginners that explains how to use Python for these sort of issues?
Thanks,
Chris Donohue, GISP
Solved! Go to Solution.
This is one of the simplest, most useful things I've seen in a while. Thanks, @DanPatterson !