Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Extract city from address

RAJ_12
5 - Atom

Hi,

 

I have data which has US addresses but there is no order in the dataset. As in there is no clear distinction as to which is city, which is street name because of no delimiters present in the address.

The State is at the end denoted by just two letters like TX for texas. The city is before that but again it is not just one word, it can be more than one word.

How can i extract city name from this?

 

Example:-   1234 XXXXX El Paso TX

                    11   XXX XXXX Garland TX

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

Hi @RAJ_12 

 

Without any exact pattern its hard to find the city. A thing what you can do is have a look up table with cities and do a find on address.

 

Hope this helps 🙂

JDong
8 - Asteroid

@RAJ_12 @atcodedog05 

 

I just split text to columns to start on a result...but maybe something can be done using Regex ?

 

Again to identify cities with more than one word...happy to see more responses.

 

Qiu
20 - Arcturus
20 - Arcturus

@RAJ_12 

Sometimes, Brutal force is beauty.

I managed to download a list of world cities then solved the puzzle.

0122-RAJ_12.PNG

atcodedog05
22 - Nova
22 - Nova

Awesome work on finding the cities dataset @Qiu 😎👍

 

If possible can you share us the link where you got the dataset.

Qiu
20 - Arcturus
20 - Arcturus

@atcodedog05 
Actually I took from a previous reply of mine.
maybe here
https://github.com/datasets/world-cities/blob/master/data/world-cities.csv

BretCarr
10 - Fireball

The main thing is that there has to be a delimiter before the city. You should use regex and keep adding to the OR statement I started for you. It is the part with the pipes:

 

(?<houseNumber>\d+) (?<streetName>.* (?:Rd|Blvd|Ave|St|Street|Avenue|Place|Pl|Parkway|Pkwy)) (?<city>[\w ]*) (?<state>[A-Z]{2})

 

I name my capture ranges so it helps breakup the expression for legibility.

 

Let me know how it goes!

atcodedog05
22 - Nova
22 - Nova

Hi @RAJ_12 

 

@Qiu 's approach of find and replace should work for your scenario provided they have the official names. Why dont you give it a try.

Labels