Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/articles/java-tutorials/)
-   -   Split a huge file in to equal parts (http://www.go4expert.com/articles/split-huge-file-equal-parts-t18368/)

naimish 6Jul2009 08:42

Split a huge file in to equal parts
 

Introduction



How to split a file in to equal parts without knowing the number of records in the input file?

Background



Suppose you don't know how many records are in a dataset, but you want to divide the records as equal as possible among the output datasets. We can split a file into equal number parts by using ICETOOL with a small keyword SPLIT / SPLITBY. The all output files will have same number of records. The below code split the file into three equal parts.

The code



Code: JCL

//SPLIT JOB TEST,'SPLIT',
// MSGCLASS=X,MSGLEVEL=(1,1),
// CLASS=B,TIME=1440,NOTIFY=&SYSUID
//JOBLIB DD DISP=SHR,DSN=SYS3.MVSV5.RUNTIME
//PSTY0010 EXEC PGM=ICETOOL,
// PARM='RC16=ABE',
// COND=(0,LT)
//INFILE DD DSN=< INPUT FILE >,
// DISP=(SHR,KEEP,KEEP)
//OUTFILE1 DD DSN=< OUTPUT FILE -1 >,
// DISP=(NEW,CATLG,CATLG),
// DATACLAS=
// DCB=
//OUTFILE2 DD DSN=< OUTPUT FILE -2 >,
// DISP=(NEW,CATLG,CATLG),
// DATACLAS=
// DCB=
//OUTFILE3 DD DSN=< OUTPUT FILE -3 >,
// DISP=(NEW,CATLG,CATLG),
// DATACLAS=
// DCB=
//TOOLIN DD *
COPY FROM(INFILE) TO(OUTFILE1,OUTFILE2,OUTFILE3) USING(CTL1)
//CTL1CNTL DD *
OPTION COPY
OUTFIL FNAMES=(OUTFILE1,OUTFILE2,OUTFILE3),SPLIT
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*


shabbir 3Aug2009 14:36

Re: Split a huge file in to equal parts
 
Nominate this article for Article of the month - Jul 2009


All times are GMT +5.5. The time now is 21:52.