Last active
September 2, 2016 20:59
-
-
Save mujuni88/0c499aabd3b76df40c1d29a0bca56888 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var readline = require('readline'); | |
var Stream = require('stream'); | |
function readFileLineByLine(inputFile, outputFile) { | |
var instream = fs.createReadStream(inputFile); | |
var outstream = new Stream(); | |
outstream.readable = true; | |
outstream.writable = true; | |
var rl = readline.createInterface({ | |
input: instream, | |
output: outstream, | |
terminal: false | |
}); | |
rl.on('line', function (line) { | |
fs.appendFileSync(outputFile, line + '\n'); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to http://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js