Page 1 of 1

To get data before commas and pipe

Posted: Wed Oct 17, 2012 5:53 am
by Cherukuri
Hi,

I have a quesion as below:

IPfield
Nafta,no2,2012|Cafta,no2,2012|bafta,no2,2012

should get a data like this below

OPfield
Nafta|Cafta|bafta

Please note the IPfield data can more with pipes.
for example i can also have data like:
Nafta,no2,2012|Cafta,no2,2012|bafta,no2,2012|Cafta,no2,2012|bafta,no2,2012

OPfield should be
Nafta|Cafta|bafta|Cafta|bafta

Could please help to figure out this logic.

Regards

Posted: Wed Oct 17, 2012 6:43 am
by chulett
Two Field() functions could pull each piece out, first delimited by pipe and then the result delimited by comma. If you are on 8.5 or higher, transformer looping can be used to iterate through the fields based on a count of the pipes.

Posted: Wed Oct 17, 2012 1:46 pm
by bhasds
Hi Cherukuri,

If you have the pattern no2,2012 is common for each delimited substring then you can use-

Code: Select all

Convert("no2,2012","",IPfield )

Posted: Wed Oct 17, 2012 2:23 pm
by ray.wurlod
With a BASIC Transformer stage you can use multi-value-handling functions such as Fields().

Code: Select all

Convert(@FM, ",", Fields(Convert("|", @FM, InLink.TheString), ",", 1, 1))

Posted: Wed Oct 17, 2012 2:26 pm
by ray.wurlod
bhasds wrote:Hi Cherukuri,

If you have the pattern no2,2012 is common for each delimited substring then you can use-

Code: Select all

Convert("no2,2012","",IPfield )
That won't work for "nafta" because every "n" is converted to "".

Posted: Mon Oct 22, 2012 1:52 am
by ShaneMuir
What version of DS are your running. 8.5? If so you can solve this with the loop functionality in the transform.