Logic to split a column 100 characters long into 4 chunks...

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
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Logic to split a column 100 characters long into 4 chunks...

Post by Minhajuddin »

Hi,

I am stuck with a tricky scenario. I have to split a column 'customer_name' which is 100 characters long into 4 chunks. The tricky part is that I am supposed to split it at spaces and also, then max number of characters in a chunk shouldn't be greater than 35. Is there a way we can do this in Datastage.

Any help is aprreciated.

Thank you.
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Transformer stage, use stage variables to help parse the text.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Look into the Index() function.....
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If volumes are not large consider using a BASIC Transformer stage with either a Fold() or a Fmt() 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.
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Since the name has to be split at spaces why not field() and then len() to find the length of the string. what should be done if the length is more than 35? Ignore the space and split it at 35th character?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Code: Select all

INDEX(In.Col[1,35],' ',DCOUNT(In.Col[1,35],' ')-1)
will give the position of the last space before position 35. Assign from position 1 to this number to the first output string, then repeat (in stage variables) for the following 3.
gaurav_shukla
Participant
Posts: 12
Joined: Wed Jun 13, 2007 2:12 am

Re: Logic to split a column 100 characters long into 4 chunk

Post by gaurav_shukla »

Minhajuddin wrote:Hi,

I am stuck with a tricky scenario. I have to split a column 'customer_name' which is 100 characters long into 4 chunks. The tricky part is that I am supposed to split it at spaces and also, then max number of characters in a chunk shouldn't be greater than 35. Is there a way we can do this in Datastage.

Any help is aprreciated.

Thank you.
We can achive such functianlity by using Transformer and Stage Variables.
In Stage Variable cut the column by using Left and Right Function like
Left(Column_Name, 25). Use such function in four stage variables and cut the column accordingly.

Hope this helps
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

guarav - the original post states that words cannot be split, which is what doing a straight substring extraction would do.
gaurav_shukla
Participant
Posts: 12
Joined: Wed Jun 13, 2007 2:12 am

Post by gaurav_shukla »

ArndW wrote:guarav - the original post states that words cannot be split, which is what doing a straight substring extraction would do. ...
In that case your's solution is correct.
I understand it wrongly!
Post Reply