AnsweredAssumed Answered

Skip over or exclude empty variable in field calculator expression

Question asked by ARC_ELA on May 7, 2018
Latest reply on May 7, 2018 by Dan_Patterson

Hello, I am trying to parse street addresses using the field calculator and return just the street name.  My expression works except for addresses where there is only a house number with no street name after it; the calculation throws an error when it gets to these bad records where the street name doesn't exist.  I would like to be able to skip over these bad addresses and just return the input string for them.  I have tried adding a second condition to my if statement, but cannot seem to get the syntax correct.  Essentially what I want to say is "if the house number is a digit and the street name is not blank, return the street name otherwise return the full input string"


def addressParser(inString):
    splitString = inString.split(' ',1)
    houseNumber = splitString[0]
    streetName = splitString[1]
    if houseNumber.isdigit() and if streetName != "":
        return streetName
        return inString


addressParser( !FULLADDRESS! )


Thanks in advance for any help