Page 1 of 1

File Split logic

Posted: Thu Nov 13, 2014 3:28 pm
by theone
Can anyone help me in getting this logic implemented using datastage please?

Below is the what the main file looks like

A200198565634
B769348348547
B837563487567
K656895565906
A387562985749
B893745647875
B394857348957
K734564735644
A893745634785
B938457348953
K783456347856
A890345765875
B378945634789
B934785643534
K378945634764

Desired Output:

File1:
A200198565634
B769348348547
B837563487567
K656895565906

File2:
A387562985749
B893745647875
B394857348957
K734564735644

File3:
A893745634785
B938457348953
K783456347856

File4:
A890345765875
B378945634789
B934785643534
K378945634764

Re: File Split logic

Posted: Thu Nov 13, 2014 4:59 pm
by hexaware_tmk
You can use @INROWNUM system variable in transformer .take 4 output links from transfrmer for each sequential file . In the constarint of each link use @inrownum to distribute the rows in each output link.

Posted: Thu Nov 13, 2014 5:38 pm
by ray.wurlod
So is it that you want a new file to start each time a line beginning with "A" occurs in the source file? This might be easier and faster to accomplish using a stream editor such as sed or awk.

If you must use DataStage, set another column to flag whether the "A" appears or not, in the form of an incrementing counter (probably maintained in a stage variable in the Transformer stage). Put this value onto the output link of the Transformer stage then use the distribution capabilities of the Sequential File stage (introduced in version 9.1) to create your files.

This is done according to a standard that you may not like, so you may need an after-job subroutine or similar to rename the files that have been created.

Posted: Thu Nov 13, 2014 11:51 pm
by chulett
theone - always best to explain your requirements in words, posting only input and output examples means we have to puzzle out what it is you need and leads to confusion and incorrect solutions. Or far too much back and forth. Start us off on the right foot. Oftentimes the simply act of spelling it out in words leads to a solution.

hexaware_tmk - there's no need to quote everything from a previous post just to reply to it. Do it when necessary but otherwise there's a perfectly lovely Reply to topic available here as well. Less flotsam for me to clean up. :wink:

Posted: Fri Nov 14, 2014 7:01 am
by battaliou
This is a classic server job using a type 1 hashed file. It will generate any amount of files you like.

Posted: Fri Nov 14, 2014 10:23 am
by theone
ray.wurlod wrote:So is it that you want a new file to start each time a line beginning with "A" occurs in the source file? This might be easier and faster to accomplish using a stream editor such as sed or ...
Thanks, I know awk or nawk works. In my question I asked logic in datastage not in unix.

Posted: Fri Nov 14, 2014 10:53 am
by theone
battaliou wrote:This is a classic server job using a type 1 hashed file. It will generate any amount of files you like.
Thank you,

Can you please throw little more light on it?

Posted: Fri Nov 14, 2014 2:10 pm
by qt_ky
theone wrote:In my question I asked logic in datastage not in unix.
Go back and read the replies completely.

Posted: Fri Nov 14, 2014 2:17 pm
by theone
Sorry, I was not able to read complete message as I did not pay. I am going back to Unix command CSPLIT or NAWK

Thank you again Ray