I am new to python. I am using a model to automate a data update process. Part of the model is to calculate a new field by concatenating 3 other fields and left trimming to remove white space as needed. Below is the VB expression. When I use python to automatically run this model it fails at the expression to calculate the field. Below is the VB expression. I cannot find an example of how this would look as a python expression. Can anyone help?
FullStreet =
LTrim( [LOCN] &" " & LTrim( [LOCD] & " " & [LOCS]))
Any help would be greatly appreciated.
Sincerely,
Nita L Hester
Assuming all fields are TEXT, this might work (note the space between the double quotes in line 2):
def processInput(input1, input2, input3): return " ".join([str(i).strip() for i in [ !input1!, !input2!, !input3!] if i]).strip() # you can also tack on .replace(" "," ") after the last .strip() to remove double spaces if needed
That worked!!!!!!!!!!
Thanks so much everyone for your assistance and thanks for your patience with a beginner.
Sincerely,
Nita
Glad it worked. It was a group effort. Check out Some Python Snippets. It will help you with learning Python.
Thanks for the info, I appreciate it.