Select to view content in your preferred language

How to use an address range value to create a new record for each address within the range?

3118
21
12-20-2016 06:47 AM
ShannonGrumbly2
Regular Contributor

I have a shapefile of parcels which contains an address for each parcel. Some of these addresses are listed as ranges (e.g. 4422-88 Wissahickon Ave). Is there a way to create a new record for each address within that range? I essentially want many addresses associated with a parcel if the parcel contains many addresses. I am assuming it would require the use of a geocoder, but I am not sure how that could be utilized. Any advice would be great!

0 Kudos
21 Replies
TimWitt2
MVP Alum

To just get the numbers create a new field called Number, right click the new field and choose Field Calculator. Switch parser to Python and type the following:

!HouseNum!.split(' ',1)[0]

then click ok

JoeBorgione
MVP Emeritus

I think the first thing I'd do is clean up those records where the  HouseNum ends in N E W or S:  Select them as such, and use a python statement smilar to what Tim provides to calc the PreDir field accordingly.  Then you can just do a search and replace on ' %'  (space any-character) and replace it with '' (no space, no character).

My guess is you got the predirs in your housnum field because there are extra spaces in your address field....

That should just about do it....
ShannonGrumbly2
Regular Contributor

How about if I wanted to remove the predirs in the housenum field, but write them to the actual predir field?

0 Kudos
JoeBorgione
MVP Emeritus

I'm not smart enough to do that in one step.  Tim probably is....  timw1984

That should just about do it....
ShannonGrumbly2
Regular Contributor

I thought I was close with this code (ending in "else: return my_direction"):

But it returns <Null> for any row where there is a W, E, S, or N attached to the end of the housenum.

0 Kudos
TimWitt2
MVP Alum

Shannon this worked for me:

Pre-Logic Script Code:

def SPLITTING(test, test2):
 if (test2 =='') :
  howmany = test.split(' ',1)
  if (len(howmany) > 1):
   return test.split(' ',1)[1]
  elif (len(howmany) == 1):
   return
 else:
  return test2

PreDir box

 SPLITTING( !HouseNum!, !PreDir! )

ShannonGrumbly2
Regular Contributor

Thanks for your response, Tim. This code does not produce anything for housenum that ends with a W, E, S, or N for me.

This is a direct copy and paste from the table:

449-57 E

I'm not sure if there's a different character or something in that value that's different from what you have.. I get "WARNING 000405: No records within table."

0 Kudos
TimWitt2
MVP Alum

Would you be able to share a view rows of your table and upload it as a shapefile here? The first 4 I see in your screenshot would be perfect.

0 Kudos
ShannonGrumbly2
Regular Contributor

Whoops! I was working in an older version of that table. It works in this table, though. Thank you!

0 Kudos
TimWitt2
MVP Alum

Glad it works!

0 Kudos