Hi All,
I need your help in implementing the below requirement in datastage
Iam having 3 columns in a sequential file with comma delimeter.And i need to write into one sequentail file..
And my testdata is ::
1A,aaa,1
2A,bbb,2
3A,cccc,3
4A,ddd,1
And i need to produce the ouput based on third column value.If the third column value contains 1 i need one copy of the row.If it contains 2 i need 2 copies of that row..
1A,aaa,1
2A,bbb,2
2A,bbb,2
3A,cccc,3
3A,cccc,3
3A,cccc,3
4A,ddd,1
Thanks in advance
Need Repetition of rows
Moderators: chulett, rschirm, roy
Need Repetition of rows
Chandra Mouli
Put the following in the filter command of the sequential file stage
Code: Select all
awk -F"," '{for (i=1; i<=$3; i++) {print $0}}'
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Yes you can. You will have to cook up a custom C routine that you can call from within the transformer. The C routine will do exactly what my awk script is doing, strip out the third column and run a loop to duplicate the row that many number of times.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
Prior to version 8.5 the lookup stage is one of the easiest ways to multiple or clone input rows.
Create a text file with the following values:
Key
1
2
2
3
3
3
4
4
4
4
etc
Join to this in a lookup stage using the Key field linked to the input counter field and set the combo box property to make this a multi value lookup. This will give you multiple output rows based on the number of lookup rows found.
Create a text file with the following values:
Key
1
2
2
3
3
3
4
4
4
4
etc
Join to this in a lookup stage using the Key field linked to the input counter field and set the combo box property to make this a multi value lookup. This will give you multiple output rows based on the number of lookup rows found.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn