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
Tricky Question
Moderators: chulett, rschirm, roy
Re: Tricky Question
not so tricky answerChampa 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
![Wink :wink:](./images/smilies/icon_wink.gif)
![Wink :wink:](./images/smilies/icon_wink.gif)
Code: Select all
cat myfilename.dat | awk -F, '{if (NR == 1) {print $1"\n"$2} else print $2}'
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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.
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
We answered the question you posed.
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.
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.