Select to view content in your preferred language

Simple question

950
5
Jump to solution
02-07-2013 11:01 AM
KellyVan_Allen
Emerging Contributor
Hi everyone,

I'm working with a large dataset, and I want to do something simple, but it's been a long time since I've used code.  I'm familiar with VB and somewhat with python.

I have full road names...(ex. Main Street, First Street) in one field.  I need to populate another field with just the 'Main' or 'First' parts of the road name.  I'm pretty sure it's a simple script, and I have a lot of records to calculate.

Any help would be appreciated!

Thanks!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Honored Contributor
Kelly,

You can do this in ArcMap using an expression in the calculate field similar to :

left([fieldname],instr([fieldname]," ")-1)

the instr function gives the position of a text string within another , and the left function extracts a string from another one

Regards

Anthony

View solution in original post

0 Kudos
5 Replies
AnthonyGiles
Honored Contributor
Kelly,

You can do this in ArcMap using an expression in the calculate field similar to :

left([fieldname],instr([fieldname]," ")-1)

the instr function gives the position of a text string within another , and the left function extracts a string from another one

Regards

Anthony
0 Kudos
MathewCoyle
Honored Contributor
It would be easier to answer if you gave a larger sample of the kinds of values in your field you want to split. Do they always end in Street/Avenue etc?

Something like this may work for you.

var.rsplit(' ', 1)[0]
0 Kudos
KendallRussell
Occasional Contributor
That isn't very easy if you need to take in to account all of the possible variations for street names and you just want the "core" name.

For example:  N FRONT AVE
                   S FRONT ST
                      FRONT PKWY

If you just want to pull 'FRONT' out of that string, then you would need to know all of the possible street directional and suffix words.  (Suffixes: ROAD, RD, AVENUE, AVE, STREET, ST, etc...  Directionals: N, NORTH, NW, NORTHWEST, NORTH WEST, etc...)

Then it gets trickier if you have a street like :  NORTH PARKWAY AVENUE 

In that case you would have to take in to account the positional value of each string and maybe assume that since AVENUE is last it must be the suffix while PARKWAY is the street name - even though PARKWAY is a valid suffix word.

My work involves handling addresses all over the United States and we have significant parsing algorithms to handle all of the possible variations.  Having said all that, you could probably write something that is relatively simple and that would handle 70% of the possible addresses correctly.
0 Kudos
KellyVan_Allen
Emerging Contributor
Thanks for the code examples!  I was able to use one of them successfully....however, I didn't take into account some of the complexities that were mentioned.  I'm going to have to write a script thats a bit more complicated!

Cheers!
0 Kudos
Zeke
by
Honored Contributor
It would be even easier if you could split the data into different fields. There are standard fields for addresses, such as prefix, direction, name, suffix, etc. Not necessarily those field names, but that's the idea. Similar to what geolocators use. Of course, that may not be an option for you.
0 Kudos