Last active
February 14, 2023 12:42
-
-
Save dcortesnet/73eb4f1e197fb86879a15e31ac289373 to your computer and use it in GitHub Desktop.
Nodejs lectura de archivo asíncono txt
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
const fs = require("fs"); | |
fs.readFile("./text.txt", "utf8", (err, data) => { | |
if (err) throw err; | |
const arr = data.toString().replace(/\r\n/g, "\n").split("\n"); | |
arr.forEach((item, index) => { | |
console.log(`Line ${index + 1} - Item: ${item}`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment