Tricky Question

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
Champa
Participant
Posts: 88
Joined: Wed Dec 14, 2005 1:44 pm

Tricky Question

Post by Champa »

All,

There are two columns as follows in a sequential file.
I am using unix to write this output. And I am reading one line at a time.

col A Col B

a 1
a 2
a 3

Output should look like

Heading a
1
2
3

Can you please help me.

Thanks
Champa
prabu
Participant
Posts: 146
Joined: Fri Oct 22, 2004 9:12 am

Re: Tricky Question

Post by prabu »

Champa wrote:All,

There are two columns as follows in a sequential file.
I am using unix to write this output. And I am reading one line at a time.

col A Col B

a 1
a 2
a 3

Output should look like

Heading a
1
2
3

Can you please help me.

Thanks
not so tricky answer :wink: :wink:

Code: Select all

cat myfilename.dat | awk -F, '{if (NR == 1) {print $1"\n"$2}  else print $2}'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Similarly in DataStage. Your single output column is derived as

Code: Select all

If @INROWNUM = 1 Then InLink.ColA Else InLink.ColB
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Champa
Participant
Posts: 88
Joined: Wed Dec 14, 2005 1:44 pm

Post by Champa »

Ray & Prabu,

Thanks

I just have bunch of ids in colA & col B.

colA colB
a 1
a 2
a 3
b 1
b 2

like that.

I have to concatenate some other fileds also.

The way I am doing is

Readseq Line

Extract diff fields

unix<-1> = F1
unix<-1> = F2

Heading a
1
2
3

then I append some more data & use mailx to send email.

loop ends here.

And I start all over for b.

Please suggest a solution for this.

In a way i need to put few lines before & after this list only once which is making my approach hard.

Thanks in advance.
Champa
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

We answered the question you posed. :roll:

The "bunch of IDs" in ColA is a new question. It is solved by sorting the input by ColA and using stage variables to detect the changes therein and to accumulate/reset the counter (ColB).

The technique has been described a number of times; search the forum for details.

Importantly, make sure that the data are partitioned using an algorithm that keeps all values in any one group in the same partition as each other.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply