Created
January 4, 2014 16:38
-
-
Save reu/8257153 to your computer and use it in GitHub Desktop.
How to read a file line by line in Node.js using the yet unstable Readline library (http://nodejs.org/api/readline.html)
This file contains 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"), | |
readline = require("readline"); | |
var reader = readline.createInterface({ | |
input: fs.createReadStream("large-file.txt"), | |
output: fs.createWriteStream("/dev/null"), | |
terminal: false | |
}); | |
reader.on("line", function(line) { | |
console.log("Line:", line); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment