-1

I have a field of data with a lot of prefixes that are difficult to remove. They involve two letters and up to three numbers that are not separated from the Street Number with a space. For instance, W238N17W Sutter Street. The address is 17 W Sutter Street. I'd like to be able to strip the postal prefix from all of the addresses in the entire field. The field has more than 150,000 addresses and they are obviously not all the same, the prefixes are not even the same length, but they all contain a letter at the start and end of the prefix.

  • 1
    What GIS software are you using? What have you tried? – PolyGeo Apr 27 '17 at 19:21
3

You could use regular expressions in field calculator. I believe this would work given your description.

Expression:

update_address(!FIELD_NAME!)

Code Block:

import re

def update_street(address): 

    return re.sub(r'[A-Z]\d{1,3}[A-Z]', "", address)

I tested it on the following data example and it works fine:

Before running field calculator (note the test data has capital letter then 1 to 3 digits followed by capital letter):

enter image description here

Run Field Calculator as shown below:

enter image description here

Output after running field calculator: enter image description here

  • Thanks for you help. I plugged these terms into the field calculator and didn't get any result. I got the error, "There was a failure during processing, check the Geoprocessing Results window for details." Can you recomend any additional step by step instructions? The data I have looks like this, N87W24887 N LISBON RD LISBON WI 53089 I would like the data look like this, 24887 N LISBON RD LISBON WI 53089 – Avram Klein Apr 27 '17 at 23:47
  • @AvramKlein I have tested and updated my answer with pictures to help. This is working for me as I originally described. I am not very good at writing code within posts so it might not have cut and pasted properly. Hopefully this helps. – ddivittorio Apr 28 '17 at 3:37
  • Thank you so much for your help. I really enjoyed readying this. My file is in Polygon Shape format. I don't have the ArcMap license necessary to convert my address polygons to points. Does the above Python script only work with points? I entered the python script into the field calculator and didn't get result from my address field. – Avram Klein Apr 28 '17 at 16:34
  • 1
    @AvramKlein No it does not only work with points it works with any field in any table (the script has nothing to do with the geometry of the feature class). Please be more descriptive with the error or results you are getting. – ddivittorio Apr 29 '17 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.