I'm trying to parse up the addresses in a table using the above code. It runs but only produces NULL
. I have run out of ideas
-
Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. What do your addresses look like? Can you please edit your question to include 3 or 4 example addresses? Also what are you expecting your output to look like?– Midavalo ♦Mar 17, 2017 at 21:50
-
Please also edit your question and put your code as text. This makes it copyable for potential answerers, and searchable for users in the future looking for a solution to similar problems.– Midavalo ♦Mar 17, 2017 at 21:52
1 Answer
You need to include a return
value to pass your new value back to your field. I don't know what your addresses look like, or the expected output, but here is an example:
Pre-logic code=
def myParser(inString):
splitString = inString.split(' ')
a = splitString[0]
c = ''.join(splitString[2:-1])
d = splitString[-1]
return "{0} {1} {2}".format(a, c, d)
Expression=
myParser(!PhysAddr!)
With a bit of a play with your code, I think your line for c
should actually be the following:
c = ''.join(splitString[1:-1]
Although it may be different if you've got different addresses to mine.