What is the best way to separate address data in a Connector?

I’d like to know what is the most efficient way to separate an address into parts (line 1, city, state, etc).
I have addresses with formats like this:
217 Court Street, Brooklyn, NY 11201
447 Third Ave. New York, NY 10016
1722 14th St Nw\nWashington, DC 20009

The separators between the street and city vary between each one, so it’s not possible to use the built in Split transformation. I was thinking of writing a function that separates these address sections, and I was wondering if it was possible to have a Yext TS function return multiple columns of data.

Like would this be possible:
Address → function → column for line 1 data, column for city data, etc

If that isn’t possible I would have to make a separate function for each item:
Address → function 1 → col for line 1
Address → function 2 → col for city

Let me know if there’s a better way or something built into the platform for this!

Yes this is possible!!
You can use the “Function on a Row Transform” to accomplish exactly that.

Alternatively, you could try using conditional transform execution to avoid TS code – this might require a few transforms but you could basically only execute a transform based on a set condition (e.g. split into columns in this way, if there are 4 spaces).

Hope this helps, and let us you know if you have any further questions!

Best,
Rachel

1 Like