Page 1 of 1

need logic

Posted: Mon Feb 04, 2008 3:39 pm
by dstest
I have 6 columns in my file.

ID,CODE1,CODE2,CODE3,CODE4,CODE5
123,300,200,500,600,20
123,400,40,30,300,20

I need the output like below

ID,CODE1,CODE2,CODE3,CODE4,CODE5
123,300,200,500,600,20,400,40,30,300,20

Can any one have any idead about how to do this in datatsage

Thanks

Re: need logic

Posted: Mon Feb 04, 2008 4:00 pm
by paddu
dstest wrote:I need the output like below

ID,CODE1,CODE2,CODE3,CODE4,CODE5
123,300,200,500,600,20,400,40,30,300,20

How many output columns you have ???

Posted: Mon Feb 04, 2008 4:46 pm
by kcbland
Seems like sorting and stage variables will do the trick.

Posted: Mon Feb 04, 2008 5:17 pm
by ray.wurlod
You have more columns than column headings in your desired output. Please be more precise about the specification of your requirement.

Posted: Mon Feb 04, 2008 9:15 pm
by htrisakti3
if I can infer by your example, you want to concatenate lines that have same ID.

Here's how i'd do it:
1. read all fields into 1 long varchar --> file1
2. using Field() read out ID, & write to hashedfile HF_id (ID, str1)
3. in another job, src=file1 ; lookup: HF_id ; out=HF_id (key=ID)
in Tfm, if ID match found --> concatenate existing value of HF_id.str1

try out & let us know..

Posted: Mon Feb 04, 2008 9:16 pm
by htrisakti3
htrisakti3 wrote:if I can infer by your example, you want to concatenate lines that have same ID.

Here's how i'd do it:
1. read all fields into 1 long varchar --> file1
2. using Field() read out ID, & write to hashedfile HF_id (ID, str1)
3. in another job, src=file1 ; lookup: HF_id ; out=HF_id (key=ID)
in Tfm, if ID match found --> concatenate existing value of HF_id.str1

try out & let us know..
sorry i meant to say that use Server job to reconstruct the file..

Posted: Tue Feb 05, 2008 4:36 am
by dhanashreepanse
You can also try this with a PX job:
1. Sort the input based on the ID column and generate Rank_Num starting from 1 wherever the ID changes.
2. Use a filter stage and have 2 outputs from it. First one filters outs all rows with Rank_Num=1 and second one filters out all rows with Rank_Num<>1.
3. Use a Join stage with a Left outer condition. Left link would be the row with Rank_Num=1. Take the required columns from the other rows on the right link.

Let us know if this works.

Regards,
Dhanashree

Posted: Tue Feb 05, 2008 4:23 pm
by ray.wurlod
:roll:
Why are you all wasting your time guessing the requirement? Why not wait until dstest posts the precise requirement, as asked?