We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Splitting address into designated columns

Masond3
8 - Asteroid

HI All, 

 

I have the following problem and it has me stumped. 

 

I am being passed two columns (ID & Full Address)

 

 

IDFull address
0001

Catalyst Inc\nBay Road\nLondonderry\nCounty Londonderry\nBT48 7TG\nBT 4 8 7 T G\nUNITED KINGDOM

0002

10 Thistle Street\nAberdeen\nAberdeenshire\nAB10 1XZ\nA B 1 0 1 X Z\nUNITED KINGDOM

 

However, I  would like to format the "full address" so its transposed into relevant columns

 

Expected Outcome :

 

IDFull addressStreet

City

State

Zip 1

Zip 2

Country
0001Catalyst Inc\nBay Road\nLondonderry\nCounty Londonderry\nBT48 7TG\nBT 4 8 7 T G\nUNITED KINGDOM

Catalyst Inc Bay Road

Londonderry

County Londonderry

BT48 7TG

BT 4 8 7 T G

UNITED KINGDOM
0002 

10 Thistle Street\nAberdeen\nAberdeenshire\nAB10 1XZ\nA B 1 0 1 X Z\nUNITED KINGDOM

10 Thistle StreetAberdeenAberdeenshireAB10 1XZA B 1 0 1 X ZUNITED KINGDOM

 

Logic :

I have noticed that the Street can contain multiple lines, so to ensure that all the correct values are mapped to the correct columns, you need to start from the back of the full address(country) and work forwards 

 

Example 

 

Country -> Zip 2 -> Zip 1  -> State  -> City 

Then anything after the 5th extraction should be bundled into street 

 

Looking forward to your response 

 

 

 

6 REPLIES 6
TheOC
16 - Nebula
16 - Nebula

Hi @Masond3 
I found an interesting way of doing it - it may not necessarily be the best.

 

Step 1:

Start with the same dataset-

TheOC_0-1677261746854.png



Step 2:
Reverse the string with a formula tool:

TheOC_1-1677261761553.png


Step 3:
Split that column into 6 columns, ensuring to select 'leave extra in last column'

TheOC_2-1677261797228.png

TheOC_3-1677261821122.png


Ignore the fact the data looks AI generated at this point 😁

Step 4:
Reverse the strings again - using a multi-field formula as they are split:

TheOC_4-1677261900267.png


This does the majority of what you needed - you can see that we have our data, and that any extra is contained in record 6.

Step 5:
Remove new line character in column '6', removing that is fairly easy with a data cleanse tool:

TheOC_6-1677262055736.png

 

 

Step 7:

Use a select tool to rename and reorder:

TheOC_7-1677262169063.png


And I believe we have it! You were totally right - we had to start from the beginning, so the way to do that was to reverse the string, and then follow the typical order.

I've attached the workflow - hopefully it should be fairly 'plug and play' with your data, but please let me know if you need any additional assistance. It follows the steps described above:

TheOC_8-1677262455165.png

 


Kind Regards,
Owen

Cheers,
TheOC
Connect with me:
LinkedIn Bulien
Masond3
8 - Asteroid

@TheOC 

Thanks for the response, i tried this out however its not giving me the outcome as listed in your post ( see Attached image)

 

for some reason i am not able to export the full address, but this is part of the address 

 

Catalyst Inc\nBay Road\nLondonderry\nCounty Lo...

 

I assume the full path way would be like this 

Catalyst Inc\nBay Road\nLondonderry\nCounty Londonderry\nBT48 7TG\nB T 4 8 7 T G\nUNITED KINGDOM

 

as you can see everything is being dumped into the "Country" field 

 

Masond3_0-1677266677257.png

 

gaoa
11 - Bolide

Hi @Masond3 

 

I tried another way to solve this (please see my workflow attached):

 

gaoa_0-1677282182738.png

 

Let me know if it works or there are any questions. Appreciate your feedback. 😊

TheOC
16 - Nebula
16 - Nebula

Hey @Masond3 
I have split based on a new line character, rather than '\n', which of these occurs when you import your raw data?
Kind Regards,
Owen

Cheers,
TheOC
Connect with me:
LinkedIn Bulien
flying008
15 - Aurora

Hi, @Masond3 

 

1- Another way for you : (there is only 2 rows data of you, could you please give 10 or more rows data for test ? )

 

录制_2023_02_25_15_11_13_982.gif

Input       
IDFull address      
1Catalyst Inc\nBay Road\nLondonderry\nCounty Londonderry\nBT48 7TG\nBT 4 8 7 T G\nUNITED KINGDOM   
210 Thistle Street\nAberdeen\nAberdeenshire\nAB10 1XZ\nA B 1 0 1 X Z\nUNITED KINGDOM    
3Street 1\nRoad 2\nOffice 3\nCity\nCityState\nZip 1\nZip 2\nCountry     
        
Output       
IDFull addressStreetCityStateZip 1Zip 2Country
1Catalyst Inc\nBay Road\nLondonderry\nCounty Londonderry\nBT48 7TG\nBT 4 8 7 T G\nUNITED KINGDOMCatalyst Inc Bay RoadLondonderryCounty LondonderryBT48 7TGBT 4 8 7 T GUNITED KINGDOM
210 Thistle Street\nAberdeen\nAberdeenshire\nAB10 1XZ\nA B 1 0 1 X Z\nUNITED KINGDOM10 Thistle StreetAberdeenAberdeenshireAB10 1XZA B 1 0 1 X ZUNITED KINGDOM
3Street 1\nRoad 2\nOffice 3\nCity\nCityState\nZip 1\nZip 2\nCountryStreet 1 Road 2 Office 3CityCityStateZip 1Zip 2Country

 

***

2- Regex to parse, so simple:

 

 

录制_2023_02_25_16_00_29_241.gif

 

BTW, maybe you can provided about 10 rows sample data to test , this is be best !

Masond3
8 - Asteroid

Hi @TheOC 

 

I can confirm that address is separated by a new line character. 

 

I looked at 80 records and 90% of the records looks good, however there is 10% where i have noticed some anomalies.

 

Looking at 80 examples, i can see that the  number of lines (line breaks) vary from  10 - 6

 

One pattern i can see is that where state = London, then City is blank

 

Consequently the "street" value  is then getting mapped into "city" and "street" is blank 

 

Example 

 

full_addressStreetCityStateZip 1Zip 22Country
50 Liverpool Street London EC2M 7PD E C 2 M 7 P D UNITED KINGDOM 50 Liverpool StreetLondonEC2M 7PDE C 2 M 7 P D UNITED KINGDOM
75 Prince Albert Road London NW8 7SA N W 8 7 S A UNITED KINGDOM 75 Prince Albert RoadLondonNW8 7SAN W 8 7 S A UNITED KINGDOM
80 Coleman Street London EC2R 5BJ E C 2 R 5 B J UNITED KINGDOM 80 Coleman StreetLondonEC2R 5BJE C 2 R 5 B J UNITED KINGDOM

 

Expected out come 

 

full_addressStreetCityStateZip 1Zip 22Country
50 Liverpool Street London EC2M 7PD E C 2 M 7 P D UNITED KINGDOM50 Liverpool Street LondonEC2M 7PDE C 2 M 7 P D UNITED KINGDOM
75 Prince Albert Road London NW8 7SA N W 8 7 S A UNITED KINGDOM75 Prince Albert Road LondonNW8 7SAN W 8 7 S A UNITED KINGDOM
80 Coleman Street London EC2R 5BJ E C 2 R 5 B J UNITED KINGDOM80 Coleman Street LondonEC2R 5BJE C 2 R 5 B J UNITED KINGDOM

 

If i assume that 10 is the max number of lines then 10-6 appears to be static ; 

Working backwards;

 

10 = Country

9 = Blank (There is a blank line between Zip 2 and country)

8 = zip 2

7 = zip 1

6 = State

 

Example - 10 Line breaks :

 

Suite E
Canal Wharf
Eshton Road
Gargrave
Skipton
North Yorkshire
BD23 3AE
B D 2 3 3 A E

UNITED KINGDOM

 

Example - 6 Line breaks :

 

No.1 London Bridge
London
SE1 9BG
S E 1 9 B G

UNITED KINGDOM

 


Regards 
Masond3

Labels
Top Solution Authors