Splitting of Values into 2 or more lines

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
poornima.chandramouli
Participant
Posts: 42
Joined: Wed Dec 26, 2007 1:58 am
Location: India

Splitting of Values into 2 or more lines

Post by poornima.chandramouli »

Hi,

I've a input file which holds a column of length 20 characters.
I've to write it in the target which has the column length as 8 characters.
So the first 8 characters should be written in first line of the column & the next 8 characters should be written to the nest line,.....

But the values of the other columns should remain same.

Code: Select all

Input:

Name    Explanation
Jai         My pet name is Huby
Ram      My Pet name is Tiger

Output:

Name    Explanation
Jai         My pet name
             is Huby
Ram       My Pet name
              is Tiger
How to achieve it in datastage.
Regards
nirdesh2
Participant
Posts: 56
Joined: Thu Nov 20, 2008 12:18 pm
Location: Noida

Re: Splitting of Values into 2 or more lines

Post by nirdesh2 »

In Transformer, use 2 output links and write first 8 chacacter is first link and rest character in second link and then use funnel stage to combine both the output.
Nirdesh Kumar
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

or easier still, convert the req char to newline.
poornima.chandramouli
Participant
Posts: 42
Joined: Wed Dec 26, 2007 1:58 am
Location: India

Re: Splitting of Values into 2 or more lines

Post by poornima.chandramouli »

nirdesh2 wrote:In Transformer, use 2 output links and write first 8 chacacter is first link and rest character in second link and then use funnel stage to combine both the output.
Hi Nirdesh,

Thanks for ur reply.
But if in the case of my input having more characteres,which has to be written in more than two lines in the output,then having 2 outputs from a transformer won't workout.
Regards
poornima.chandramouli
Participant
Posts: 42
Joined: Wed Dec 26, 2007 1:58 am
Location: India

Post by poornima.chandramouli »

Sainath.Srinivasan wrote:or easier still, convert the req char to newline.
Hi Sainath,

Could you please elaborate a bit.
Regards
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

In pseudocode.....

If you find that 'n'th char is where you need to break, do it like

Code: Select all

keyField = keyField
nonKeyField = nonKeyField[1, n - 1] : newlineChar : nonKeyField[n + 1, 9999]
I will leave it to you to derive the value of 'n' and 'newlineChar'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you're prepared to use a server job this is a very easy task.

Code: Select all

Convert(@TM,@FM,Fmt(InLink.TheString,"8L"))
and write to a text file.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dganeshm
Premium Member
Premium Member
Posts: 91
Joined: Tue Aug 11, 2009 3:26 pm

Post by dganeshm »

Sainath.Srinivasan wrote:In pseudocode.....

If you find that 'n'th char is where you need to break, do it like

Code: Select all

keyField = keyField
nonKeyField = nonKeyField[1, n - 1] : newlineChar : nonKeyField[n + 1, 9999]
I will leave it to you to derive the value of 'n' and 'newlineChar'


Need help to define the 'newlineChar' , if I give '\n' it doesnt recognise it and loads it as '\n' , what should be the value of newlingChar so that it is recognised...
Regards,
Ganesh
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

This gives a new line character
Char(10)
You are the creator of your destiny - Swami Vivekananda
dganeshm
Premium Member
Premium Member
Posts: 91
Joined: Tue Aug 11, 2009 3:26 pm

Post by dganeshm »

anbu wrote:This gives a new line character
Char(10)
Thanks Anbu..
Regards,
Ganesh
Post Reply