datastage function

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

datastage function

Post by pavan_test »

Hi All,

I have a column that contains data such as

notes=dsadssa, sdsaddsa, dsaddfdfd, fdfdfdsfdsfds

whereever there is comma(followed by single space) I have to write a semi colon.

expected output:

notes=dsadssa;sdsaddsa;dsaddfdfd;fdfdfdsfdsfds

can someone please let me know how can I do this datastage

Thanks
pavan
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: datastage function

Post by SURA »

If always you will get the single space after comma?

Trim (col,' ',':')

Or

You can use convert function too.

DS User
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search DSXchange for the pxEreplace function, which will handle your requirement even if there are spaces and commas in your data.

Otherwise do what SURA was attempting to suggest - Trim() to get rid of the spaces and Convert() to change the commas to semi-colons.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

datastage function

Post by pavan_test »

I Apologize, actualy it is other way around..

where ever there are semi-colons, I have to replace them with , (followed by single space)

notes=dsadssa;sdsaddsa;dsaddfdfd;fdfdfdsfdsfds

desired output:

notes=dsadssa, sdsaddsa, dsaddfdfd, fdfdfdsfdsfds

how can I do it using convert function

Thanks
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Code: Select all

Convert(";",", ",input_column)
Try this, but i am not sure whether you will get any space after the comma.

Try this and let us know!
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Convert() replaces single character by another single charcter.
I dont think it will work in your case.
Yu can search PXEReplace() or use sed or awk in before/after job subroutine for this purpose.

Thanks
pandeeswaran
BradMiller
Premium Member
Premium Member
Posts: 87
Joined: Mon Feb 18, 2008 3:58 pm
Location: Sacramento, CA

Post by BradMiller »

Convert() replaces single character by another single charcter.
I have seen this posted on DSXChange before, but I have not found it to be true. I ran a quick test, using the "Convert" solution and found it worked per the o/p's requirement. Is it possible this is how Convert worked in earlier versions? I am using 8.1.

Code: Select all

Convert(';',', ',DSLink2.RawData)
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Convert() will not work here. As Pandeesh mentioned, it replaces single characters with other single characters--";" with ",". It will not replace a single character with a string of characters--";" with ", ".

As mentioned already, pxEreplace() for parallel is available for installation and will serve the purpose...also you can write your own parallel routine if you wish, use a Basic Transformer instead or even an external filter (awk or sed for example).

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

jwiles wrote:use a Basic Transformer instead or even an external filter (awk or sed for example).

Regards,
James,

why BASIC transformer?
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

BASIC Transformer has in-built Ereplace() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Thanks Ray!! I forgot!! :)
pandeeswaran
Post Reply