Replace a string with another string

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
MANASHI
Participant
Posts: 17
Joined: Thu Mar 20, 2014 2:50 am
Location: kolkata

Replace a string with another string

Post by MANASHI »

Hi All,
I have a requirement to replace a string with another string or just removing that string in datastage 8.5. And that string may appear more than once. Is there any function in DS 8.5 which does this? Please let me know. From this forum I got to know that we can write a routine to do this. But I was just wondering if there are any built in functionality to do this.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Split off from this conversation on the same topic. And the answer is still no until you get up into the 9.x release, from what I recall.
-craig

"You can never have too many knives" -- Logan Nine Fingers
MANASHI
Participant
Posts: 17
Joined: Thu Mar 20, 2014 2:50 am
Location: kolkata

Post by MANASHI »

Do we have any other work around using index, left, right? But probably in that case also, we will have to loop through. :(
MANASHI
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You... could, I imagine. Seems like it would be fairly painful, though. I would think the PXEReplace function linked to in the other post would be a better option.
-craig

"You can never have too many knives" -- Logan Nine Fingers
MANASHI
Participant
Posts: 17
Joined: Thu Mar 20, 2014 2:50 am
Location: kolkata

Post by MANASHI »

Thanks. I also feel so.
Do you have the BASIC code for erplace function for parallel jobs? Could you please share that?
MANASHI
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Others might but I no longer do.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vik1979
Participant
Posts: 9
Joined: Thu Oct 21, 2010 3:22 am

Post by vik1979 »

Yes, I think you can use Ereplace function in transformer stage.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A BASIC Transformer stage, sure. That's another option.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

pxEreplace() is a parallel function created for and improved on this site. A Search should find it for you.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As noted, there's a link to it in the post this was split from. However, I seem to remember chatter there about memory leaks and other issues with it when Phil played with it last. [shrug]
-craig

"You can never have too many knives" -- Logan Nine Fingers
MANASHI
Participant
Posts: 17
Joined: Thu Mar 20, 2014 2:50 am
Location: kolkata

Post by MANASHI »

Thank you so much. I will try the basic transformer stage first. Do we have any disadvantages on that? I think it runs sequentially.
MANASHI
atul9806
Participant
Posts: 96
Joined: Tue Mar 06, 2012 6:12 am
Location: Pune
Contact:

Post by atul9806 »

Yes, Use of basic transformer in parallel job have some drawbacks but It DEPENDS.. About your questions - No, It is running Parallel ( by default ) as well as Sequencial. The Only drawback is It will invoke the SERVER ENGINE for executing the BASICs function used in BASIC transformer.

px version of Ereplace()
viewtopic.php?t=106358
~Atul Singh
<a href=http://www.datagenx.net>DataGenX</a> | <a href=https://www.linkedin.com/in/atulsinghds>LinkedIn</a>
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Post by ssnegi »

String INPUT.COL : This is a String.This should be used.This is good.
stage variable :
cnt : count(INPUT.COL,'This')
Loop Variable :
cnt1 Initial Value 0 : if cnt1 = 0 then cnt else cnt1-1
lfind1 :
if cnt1 = cnt then field(INPUT.COL,'This',1):'That':INPUT.COL[Index(INPUT.COL,'This',1)+len('This'),len(INPUT.COL)]else field(lfind1,'This',1):'That':lfind1[Index(lfind1,'This',1)+len('This'),len(lfind1)]
Loop While : cnt1 <> 1
Constraint : cnt1 = 1
OUTPUT : That is a String.That should be used.That is good.
The "This" recurring string is replaced with "That". You can use the same logic to remove the string. Instead of 'That' put ''.
Post Reply