Hello everyone,
What would be the field calculator script code to only extract the numbers and nothing else from the fieldname column to hnum column?
a = '12ab34cd5'
b = int("".join([i for i in a if i.isnumeric()]))
# in field calculator
# python parser of course
int("".join([i for i in !YourFieldNameHere! if i.isnumeric()]))
Thankyou Dan
no problem Emmanuel
Here is a thread I started some time ago: https://community.esri.com/thread/163731 It might give some insight to using Python to parse out address components.
Something I noticed in your sample data and it's quite common with address data, and that is the lack of consistency. Your third record has no house number; I realize it's probably a dummy record but those kinds of inconsistencies need to be handled or your parser will error out once it hits a line like that. So either make sure your data is clean, or trap errors in your script.
Joe ,
Yes, you are correct. There can also be other values that are completely blank which can cause further issues. But for what i was trying to do it was helpful to get an idea for where to start.
Dan's code was helpful for the start, which helped me make labels from Label Expression Window instead of having to maintain a new field. This was mainly for Home Number Label service.
int("".join((i for i in [YourField] if i.isnumeric())))
This expression neglects all the blank values, and the fields without the numbers in them.