Split Files Using sort in to multiple files



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Split Files Using sort in to multiple files

Postby rszode » Tue Dec 24, 2013 11:02 pm

Hi Team
I have a input file which is having many header which is common value as below ( Header - ONDEMAND INDEX ) , now i want this files to be divided in 2 or 3 files based on count of header in this case ( ONDEMAND INDEX ), please help me on this

Input File :

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------


Suppose Result needs files to be divided in 3 files after 2 count of "ONDEMAND INDEX"

Out put file : 1

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------

Out put file : 2

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------

Out put file : 3

ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
ONDEMAND INDEX
-----Data Part----IT CAN BE ANY NUMBER OR CHARS------
rszode
 
Posts: 2
Joined: Tue Dec 24, 2013 10:36 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split Files Using sort in to multiple files

Postby Akatsukami » Wed Dec 25, 2013 1:54 am

As this requirement cannot be fulfilled using the forum rules, you should have chosen a different area to post in :roll:
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Split Files Using sort in to multiple files

Postby BillyBoyo » Wed Dec 25, 2013 8:41 pm

Your post has been moved. Don't know which SORT product you use, so let us know, it may have to move again.

Use WHEN=GROUP, and PUSH an ID and have an appropriate number of OUTFIL INCLUDE=( for the range of ID values you want. If that is not it, describe your problem a bit more clearly.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Split Files Using sort in to multiple files

Postby rszode » Wed Dec 25, 2013 9:38 pm

Hi Thanks for reply, i want to use aany sort which gives me result as expected.let me provide example in simple way as below

Here in input file Key word AAAAAAAA occur 6 time in file, so i want to divide this file in 3 file, but along with its parts present below it. like 'abcdefssdadadad' see in exa.

Input File :
AAAAAAAA
abcdefssdadadad
sdasdsadsadadad
fdfdfdfdfdsgdsddf
AAAAAAAA
dsdasdasdsa
AAAAAAAA
rfggfdgfgffgf
bvcxvcxvcxv
AAAAAAAA
dgdsgfdgthtytb
AAAAAAAA
retewtretrtrrtr
AAAAAAAA
wddsadasdsad
fgdsgdsgdfsg

Expected output files

OUTPUT FILE 1
AAAAAAAA
abcdefssdadadad
sdasdsadsadadad
fdfdfdfdfdsgdsddf
AAAAAAAA
dsdasdasdsa

OUTPUT File 2

AAAAAAAA
rfggfdgfgffgf
bvcxvcxvcxv
AAAAAAAA
dgdsgfdgthtytb


OUTPUT File 3

AAAAAAAA
retewtretrtrrtr
AAAAAAAA
wddsadasdsad
fgdsgdsgdfsg
rszode
 
Posts: 2
Joined: Tue Dec 24, 2013 10:36 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Split Files Using sort in to multiple files

Postby BillyBoyo » Thu Dec 26, 2013 3:46 pm

You can't just use "any sort", you have to use the one installed at your site. We don't know which that is.

You need to consult your manual(s) and become familiar with IFTHEN=(WHEN=GROUP and PUSH= with an ID.

Once your groups of records have a value which can be used to keep them together (the ID) then it should be easy to distribute them to one of multiple output files using OUTFIL INCLUE=/OMIT=.

Try it, one thing at at time, and let us know if you get stuck, showing what you tried, what actually happened, what you expected to happen, and input data to create the problem. We need to know the RECFM and LRECL of your files as well.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post