split a 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Using the appropriate functions in a Modify stage or a Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abhay10
Participant
Posts: 31
Joined: Tue Nov 20, 2007 11:39 pm
Location: Bangalore

Post by abhay10 »

ray.wurlod wrote:Using the appropriate functions in a Modify stage or a Transformer stage. ...

i know that, but which function?
lokesh_vee
Participant
Posts: 3
Joined: Tue Oct 23, 2007 11:57 pm

Post by lokesh_vee »

If you want to execute the substring operation through transformer then below is an example what you can refer.

Input1 - column name

expression in the transformer stage expression editor.

Input1[1,3]

note: 1 is the starting position and 3 is the string length.

if your Input1 data is "SUBSTRING". After passing through the transformer it will result as "SUB".

Hope this helps......
Masters are never born. But they become one by experience.
abhay10
Participant
Posts: 31
Joined: Tue Nov 20, 2007 11:39 pm
Location: Bangalore

Post by abhay10 »

lokesh_vee wrote:If you want to execute the substring operation through transformer then below is an example what you can refer.

Input1 - column name

expression in the transformer stage expression editor.

Input1[1,3]

note: 1 is the starting position and 3 is the string length.

if your Input1 data is "SUBSTRING". After passing through the transformer it will result as "SUB".

Hope this helps......

i want it as SUB STRING(ie space in between) and not only SUB
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use the LEFT() and RIGHT() functions in the transformer stage and concatenate a space in between.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
NickH
Participant
Posts: 6
Joined: Mon Jul 26, 2004 7:46 am

Post by NickH »

abhay10 wrote:
lokesh_vee wrote:If you want to execute the substring operation through transformer then below is an example what you can refer.

Input1 - column name

expression in the transformer stage expression editor.

Input1[1,3]

note: 1 is the starting position and 3 is the string length.

if your Input1 data is "SUBSTRING". After passing through the transformer it will result as "SUB".

Hope this helps......

i want it as SUB STRING(ie space in between) and not only SUB
Simply use Input1[1,3]:' ':Input1[4,LEN(Input1)-3]
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

NickH wrote: Simply use Input1[1,3]:' ':Input1[4,LEN(Input1)-3]
That's if your input data is to be ALWAYS split with 3 characters in the first word followed by a space and rest of the characters.

What is your criteria for splitting a word into 2?
gateleys
NickH
Participant
Posts: 6
Joined: Mon Jul 26, 2004 7:46 am

Post by NickH »

gateleys wrote:
NickH wrote: Simply use Input1[1,3]:' ':Input1[4,LEN(Input1)-3]
That's if your input data is to be ALWAYS split with 3 characters in the first word followed by a space and rest of the characters.

What is your criteria for splitting a word into 2?
The criteria was implied that the split happened between the 3rd and 4th character.

As there are many ways to do it, this was just an example that could be adjusted easily, I prefer to start simple and work up to complex :wink:

If you want to get more interesting you could go for

where v_LenStartString is the length of the first part of the string

Then it would be

Input1[1,v_LenStartString]:' ': Input1[(v_LenStartString+1),LEN(Input1)-v_LenStartString]

or perhaps

EReplace(Input1,Input1[1,v_LenStartString],Input1[1,v_LenStartString]:' ',1,1)

but I prefer simple as its easier to maintain in the long run
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

NickH wrote: I prefer simple as its easier to maintain in the long run
Me too... like this one -

Code: Select all

Fmt(Arg1,"L#3 #":Len(Arg1)-3)
:wink:
gateleys
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Guys, lets not carried away, both EREPLACE() and FMT() do not exist in px. Lets wait for the OP to come back with a rule.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

DSguru2B wrote:Guys, lets not carried away, both EREPLACE() and FMT() do not exist in px. Lets wait for the OP to come back with a rule.
:oops: :oops:

Gotta get one of those Server To Parallel Transition Trainings. Any idea if there is one in the near future.

But what's the point? We don't have an EE here.
gateleys
abhay10
Participant
Posts: 31
Joined: Tue Nov 20, 2007 11:39 pm
Location: Bangalore

Post by abhay10 »

thanks everyone i got it by concatenating space using left and right...
Post Reply