Select to view content in your preferred language

edit selected attributes using rules

188
7
Jump to solution
4 weeks ago
dsinha
by
Frequent Contributor

Hello,

I am trying to join a table to feature class using a field (parcel ID) that is common to both of them. However, around 700+ parcel IDs (out of 6500+) are formatted incorrectly. For example:

  • 51-23-0600-015-UI15 vs. 51-23-0600-015UI15
  • 06-20-1798-139-EX vs. 06-20-1798-139EX

I am trying to figure out how to edit these unmatched values in ArcGIS Pro so that the join proceeds. Is there a way to apply a rule - e.g. remove the 15th character (-) from the values on the left so that they match the values on the right?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
CodyPatterson
MVP Regular Contributor

Hey @dsinha 

That is my bad I should have attached a screenshot, it should look something like this:

CodyPatterson_0-1754407599572.png

Cody

View solution in original post

7 Replies
CodyPatterson
MVP Regular Contributor

Hey @dsinha 

If these are incorrect, would it be possible to just fix them? If the - is always at the 15th slot, you could use a calculate field function to fix this:

def remove(item):
    if item and len(item) >= 15 and item[14] == "-":
        return item[:14] + item[15:]
    return item

I would test this on a small subset of data to ensure this does what you're expecting!

Cody

0 Kudos
dsinha
by
Frequent Contributor

Thanks so much for your help @CodyPatterson!

I tried to run the expression but I got an error message (though the expression is valid):

dsinha_1-1754407113009.png

 

 

 

0 Kudos
CodyPatterson
MVP Regular Contributor

Hey @dsinha 

That is my bad I should have attached a screenshot, it should look something like this:

CodyPatterson_0-1754407599572.png

Cody

dsinha
by
Frequent Contributor

Thanks so much for sending the screenshot @CodyPatterson. Worked like a charm!

0 Kudos
dsinha
by
Frequent Contributor

@CodyPatterson just curious - what would the expression look like if I want to remove any "-" after the 14th character?

0 Kudos
CodyPatterson
MVP Regular Contributor

Hey @dsinha 

It should look something like this, you'd just have to rebuild the string which this does:

def remove(item):
    if item and len(item) > 14:
        prefix = item[:14]
        suffix = item[14:].replace("-", "")
        return prefix + suffix
    return item

As with all code, just make sure that this is valid for your purposes and doesn't indirectly edit anything else!

 Cody

dsinha
by
Frequent Contributor

Oh, this is beautiful! I wish I had your skills @CodyPatterson! Thanks a million! 

0 Kudos