Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 27, 2018 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/18b4acd7534fc55d7a4d859334eadc5f to your computer and use it in GitHub Desktop.
Save parzibyte/18b4acd7534fc55d7a4d859334eadc5f to your computer and use it in GitHub Desktop.
Leer archivo de texto línea por línea en Node.JS created by parzibyte - https://repl.it/@parzibyte/Leer-archivo-de-texto-linea-por-linea-en-NodeJS
Hola, soy un archivo de texto para demostrar algunos tutoriales de parzibyte.me. Puedo contener cualquier tipo de contenido, por ejemplo, saltos,
tabulaciones
y cualquier
otra
cosa.
/**
* Leer un archivo con Node.JS línea
* por línea usando fs y readline
*
* @author parzibyte
*/
const readline = require("readline"),
fs = require("fs"),
NOMBRE_ARCHIVO = "archivo.txt";
let lector = readline.createInterface({
input: fs.createReadStream(NOMBRE_ARCHIVO)
});
lector.on("line", linea => {
console.log("Tenemos una línea:", linea);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment