Select to view content in your preferred language

Compare address fields

895
5
11-29-2022 12:40 PM
Labels (3)
GreggWolin
Emerging Contributor

I have a dataset of properties where the site address (Address, City, State, Zip) is contained within 1 field, while the postal address is broken into individual Address, City, State and Zip fields.

I need to identify the records where the addresses match. 

0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

could you show a record or two.

You could make it easier if you produced a similar field with the concatenation done in the field calculator.  You could compare those fields easily.  Assuming python and your fields are names as you suggest, and commas separate the values in the comparison field,

r"{}, {}, {} {}".format(!Address!, !City!, !State!, !Zip!)

... sort of retired...
0 Kudos
GreggWolin
Emerging Contributor

Here you go. The "Match" column is what I'd like to create. Basically, if the first 5 characters match then 1, else 0

SiteAddressPostalAddressMatch
37211 W OLIVETO AVE MARICOPA, AZ 85138MAIL RETURN0
37269 W OLIVETO AVE MARICOPA, AZ 85138PO BOX 23160
37289 W OLIVETO AVE MARICOPA, AZ 8513837289 W OLIVETO AVE1
36990 W NOLA WAY MARICOPA, AZ 8513815771 RED HILL AVE STE 1000
37120 W OLIVETO AVE MARICOPA, AZ 8513837120 W OLIVETO AVE1
36850 W NOLA WAY MARICOPA, AZ 85138PO BOX 5190
36866 W NOLA WAY MARICOPA, AZ 8513836866 W NOLA WAY0

 

 

0 Kudos
DanPatterson
MVP Esteemed Contributor

Code block, python parser.

Expression :  match(!SiteAddress!, !PostalAddress!)

 

def match(fld0, fld1, chars=5):
    """match first `chars` in two fields"""
    if fld0[:chars] == fld1[:chars]:
        return 1
    return 0

 


... sort of retired...
0 Kudos
GreggWolin
Emerging Contributor

1. Where does the "Expression" go?

2. The table has a bunch of fields (I just included 2 for the illustration). Do i use the column# of the "visible" fields or of "all" fields? 

0 Kudos
DanPatterson
MVP Esteemed Contributor

Calculate Field Python examples—ArcGIS Pro | Documentation

fieldcalc.png

Well the code won't work, It would get real ugly fast if you want to slice and compare multiple values from multiple slices in multiple fields to slices from one input field

As I said earlier, it would be easier if you added a new field and concatenated the values from the fields you want to replicate the full address.  Then, you can compare the two fields directly


... sort of retired...
0 Kudos