Page 1 of 1

Create output files dynamically

Posted: Fri Mar 30, 2012 12:52 am
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?

Posted: Fri Mar 30, 2012 1:46 am
by kandyshandy
I guess posting this in UNIX forum would help ;)

Posted: Fri Mar 30, 2012 5:46 am
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.

Posted: Fri Mar 30, 2012 7:53 am
by chulett
You might also look into the csplit function.

Posted: Fri Mar 30, 2012 2:54 pm
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.