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.
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!)
Here you go. The "Match" column is what I'd like to create. Basically, if the first 5 characters match then 1, else 0
SiteAddress | PostalAddress | Match |
37211 W OLIVETO AVE MARICOPA, AZ 85138 | MAIL RETURN | 0 |
37269 W OLIVETO AVE MARICOPA, AZ 85138 | PO BOX 2316 | 0 |
37289 W OLIVETO AVE MARICOPA, AZ 85138 | 37289 W OLIVETO AVE | 1 |
36990 W NOLA WAY MARICOPA, AZ 85138 | 15771 RED HILL AVE STE 100 | 0 |
37120 W OLIVETO AVE MARICOPA, AZ 85138 | 37120 W OLIVETO AVE | 1 |
36850 W NOLA WAY MARICOPA, AZ 85138 | PO BOX 519 | 0 |
36866 W NOLA WAY MARICOPA, AZ 85138 | 36866 W NOLA WAY | 0 |
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
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?
Calculate Field Python examples—ArcGIS Pro | Documentation
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