Skip to content

Instantly share code, notes, and snippets.

@reu
Created January 4, 2014 16:38
Show Gist options
  • Save reu/8257153 to your computer and use it in GitHub Desktop.
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)
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