Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Use Field Calculator to create mailing address block

$
0
0
I have a table that has all the attributes of a feature broken out into individual fields. I would like to assemble the fields into a printable mailing label. Some of the fields may or may not have values, and should only be included if they do. I tried to set this up to be fairly generic so I can reuse it, but I'm having trouble passing multiple values. Any help would be appreciated.
From Pre-logic code:
Code:

def strFunction(myFields[]):
  returnString = ''
 
  for thisField in myFields:
    if(not IsNull(thisField);
      returnString = returnString + thisField
  return returnString

Expression:
Code:

mailLabel = strFunction(!ownerName!, !addressLine1!, !addressLine2!)
I can work out the string formatting as soon as the code works.

Viewing all articles
Browse latest Browse all 2485

Trending Articles