Create output files dynamically

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
deepa.y
Participant
Posts: 56
Joined: Mon Nov 28, 2011 10:47 pm
Location: Bangalore

Create output files dynamically

Post by deepa.y »

Hi,
I need to create output files for distinct values in col1 and put corresponding data into those files.
input file:
col1,col2
1,xx
1,yy
2,zz
So,i read the posts and implemented the logic by using the awk command
awk '{nPosField1=index($0,",");print substr($0,nPosField1+1)>substr($0,1,nPosField1-1)}' in external target stage
by giving input as file name in column1 and data in column2 from a transformer.
This worked fine when my record delimeter is end or newline.
I need my record delimeter to be \x00 and final delimeter to be none.
so that my Output will be
out_1.txt->1,xx^@1,yy^@
out_2.txt->2,zz^@

In this case the above command will not hold good as the records are not in new line.Please suggest me how to achieve this?
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

I guess posting this in UNIX forum would help ;)
Kandy
_________________
Try and Try again…You will succeed atlast!!
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

How about using a Sequential File stage as the target instead of an awk command? Sequential File stage lets you choose delimiters and newline settings.
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You might also look into the csplit function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Server jobs have a Folder stage that does this. You could use one of those in a server Shared Container in a parallel job, or maybe do all of your processing in a server job.
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