Dynamic output files

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
dsconultant
Participant
Posts: 10
Joined: Sat Dec 05, 2009 2:05 pm

Dynamic output files

Post by dsconultant »

Hi,
I have a data file which has output like following

abc20091011
abc20091011
abc20091111
abc20091111
xyz20091011
xyz20090909

I need separate files for abc20091011, abc200911, xyz20090909 and so on. Problem is the output is dynamic. It could have any number of records. Right now I have 4 unique data but it will change to maybe 20 in my next run. So for each unique record I need separate file. How can I handle this?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm not sure if there are any stage in PX that would allow output to dynamic files, perhaps the External Target stage? Server allegedly does - the Folder stage but to be honest I've never used it in that fashion. Or you could always go the 'build op' route and put together something in C++ to do that for you.

Another possibility is building a single file and then 'splitting' the file post job, using something like csplit perhaps.
-craig

"You can never have too many knives" -- Logan Nine Fingers
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Datastage parallel (C++) routine to create files dynamically

Post by JoshGeorge »

Link to - Datastage parallel (C++) routine to create files dynamically for every record in single job.

http://it.toolbox.com/blogs/dw-soa/data ... ally-21095
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
dsconultant
Participant
Posts: 10
Joined: Sat Dec 05, 2009 2:05 pm

Post by dsconultant »

Thanks, I will try the routine.
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

Post by vinnz »

You could try awk as well to post-process your file as suggested above

awk '{ print >> $1 ; close($1)}' yourfilename
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

if you want to do in datastage then , in a transformer stage do a mapping like

'echo ':INPUT_COLUMN:' >> ':INPUT_COLUMN:'.txt'

and the in after job subroutine, just execute the target file.
Post Reply