Python does allow for <null> check in field calculator.Open field calculator, choose the Python Parser.Check the "Show Codeblock" boxEnter the following in the "Pre-Logic Script Code:" boxdef Concatenate(field1,field2):
if field2 == "":
return field1
else:
return field1 + '-' + field2
in the bottom box enter (change the stuff between the !'s to your actual field names):Concatenate(str(!MyField1!), str(!MyField2!))
This works because the null values ( <null> ) are converted to empty strings before being sent to the custom "Concatenate" function build in the code block. More info can be found at this linkAdditional options:if both fields contain <null> values and/or you want to you want to retain said <null> values... this example code should help:Parser: PythonPreLogic:def myFunction(one,two):
if one == "": # check if first field is <null>
if two == "": # check if both fields are <null> and returns <null>
pass
else:
return two # otherwise, just return the second field value
else: # check if the first field is populated...
if two == "": # if second field is blank
return one # return just the first field
else: # if both fields are populated
return one + "-" + two # return a concatenation of the fields with a hyphen deliminator
Calculation box:myFunction(str(!field1!), str(!field2!))