shlogg · Early preview
Judy @esproc_spl

Split Large CSV File Into Smaller Files With SPL In Java

Split large CSV file into smaller files using Java: use SPL code to divide file into parts with ordinal numbers like Orders1.csv, each part <5M.

A csv file has a size far greater than 5M. Below is part of its data:

Use Java to do this: Split the file into smaller files, each having a size of about 5M; file names contain ordinal numbers, such as Orders1.csv and Orders2.csv. One record should only be put into one file.
Write the following SPL code:

A2: Compute the number of smaller files (N) the csv file will be divided into. Symbol \ performs the division and gets only the integer part; +1 makes the size of each smaller file is a bit less than 5M.
A3: Loop from 1 to N: approximately, divide the large file into N parts according to the...