picking some part from the 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
skumar
Participant
Posts: 88
Joined: Thu May 25, 2006 5:11 am
Location: Hyderabad

picking some part from the string

Post by skumar »

Hi All

I have a requirement that from a particular string "The Customer has recently made an application for a new account" I need to pass the value into 2 different columns. Now the issue is in the first column is of 20 length and second column is of 150 length. when I am taking the first 20 characters from the source string the target column will be populated with the value"The Customer has rec". But I want the first column to be popualted with "The Customer has" and the second column should start/load with "recently made an application for a new account".

Can you please advise how we can acheive this.

Thanks in advance

Regards
skumar
robjones
Participant
Posts: 24
Joined: Tue Nov 18, 2008 3:12 pm
Location: London

Post by robjones »

What criteria do you need to use to break up the string into two parts?

Do you just want to take complete words up which make up 20 characters or less into the first column, and then pass the remaining complete words into the second column?
skumar
Participant
Posts: 88
Joined: Thu May 25, 2006 5:11 am
Location: Hyderabad

Post by skumar »

yes rob you are correct.
skumar
Participant
Posts: 88
Joined: Thu May 25, 2006 5:11 am
Location: Hyderabad

Post by skumar »

yes rob you are correct.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Search for Count and Index.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

From what I remember, Ray has posted about the Fold() function for requirements like this. Never looked up what it did, however.
-craig

"You can never have too many knives" -- Logan Nine Fingers
robjones
Participant
Posts: 24
Joined: Tue Nov 18, 2008 3:12 pm
Location: London

Post by robjones »

Create a stage variable, svBreak, with the following:

Code: Select all

Index(link.InputString, " ", Count(link.InputString[1,20], " ") )
Then your column derivations will be:


Col1

Code: Select all

link.InputString[1, svBreak -1]
Col2

Code: Select all

link.InputString[svBreak,150]
Last edited by robjones on Wed Oct 07, 2009 6:41 am, edited 1 time in total.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Fold() is a basic function that provides break by delimier.
JRodriguez
Premium Member
Premium Member
Posts: 425
Joined: Sat Nov 19, 2005 9:26 am
Location: New York City
Contact:

Post by JRodriguez »

Stage Variables

sv1 = InputOrigString[1,20]
LastSv1Char = sv1[1]
sv2 = InputOrigString[21, ( len(InputOrigString) + 1)]
LastSv2Char =sv2[1,1]
svCountSpaces = count(sv1, " ")
svPosition = Index (InputOrigString, " ", svCountSpaces)


Columns derivations
targetCol1= If ( LastSv1Char <> " " and LastSv2Char <> " " ) Then InputOrigString[1, (svPosition - 1)] Else sv1
targetCol2= If ( LastSv1Char <> " " and LastSv2Char <> " " ) Then InputOrigString[svPosition, ( len(InputOrigString) - svPosition )] Else sv2
Julio Rodriguez
ETL Developer by choice

"Sure we have lots of reasons for being rude - But no excuses
Post Reply