Created
December 27, 2018 13:21
-
-
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
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
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. |
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
/** | |
* 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