A NodeJS module that splits a file into parts while preserving lines.
npm install split-by-lineInstall with npm install split-by-line
##Example
Split by line splits a file into a specified number of files but preserves the lines of the file.
``Javascript
const splitByLine = require('split-by-line');
splitByLine('file.txt', {
number: 3
}, function(err, files) {
// files is an array with the resulting filenames
console.log(files);
// Prints:
// ['file.txt.part0', 'file.txt.part1', 'file.txt.part2']
});
`
- the first parameter is the file that gets split
- the second parameter are optional options
- the callback will be called with
err and files, where files is an array containing the file names of the created filesCurrently it is not guaranteed that the lines stay in order
$3
`Javascript
options = {
number: 2, // The number of files that are created (1000 is maximum)
keepEmpty: true, // If the number of files is bigger than the number of lines, decide whether to keep the remaining empty files or not
outputDir: path.dirname(inputFile), // The folder in which the files are stored
minLines: 1 // The minimum number of lines one file should have.
}
``