Error Trapping

3606
4
07-20-2015 01:06 PM
JoeBorgione
MVP Esteemed Contributor

I need to parse out address elements (house-num, pre-dir, street-name, suf-dir, street-type) from a single string field into individual fields. All my addresses should in the form of pre-dir, house-num, street-name, suf-dir or suf-type depending on the street name

Not a big deal, but my current script errors out with a 999999 error.  This tells me that somewhere down the line I have an address that does not follow the form above (hence should...)  At any rate is there a way to trap the error in such a fashion that I and make it an exception, or give me the record oid of the offending record?

Version 10.2.2 arcgis, appears to be Python 2.7.5 installed:

can't wait to retire....
0 Kudos
4 Replies
WesMiller
Regular Contributor III

Did you try the standardize address tool

JoeBorgione
MVP Esteemed Contributor

I more or less did it that on my own and found the offending records, fixed them and ran the script.

can't wait to retire....
0 Kudos
IanMurray
Frequent Contributor

Hey Joe,

You can catch the error in a try-except block.  This should allow your script to run on the rest of your values, and you can put messages in the except block telling which features had the issue.

See https://docs.python.org/2/tutorial/errors.html section 8.3

JoeBorgione
MVP Esteemed Contributor

I'll give this a try.

can't wait to retire....
0 Kudos