Skip to content

Instantly share code, notes, and snippets.

@dcortesnet
Last active February 14, 2023 12:42
Show Gist options
  • Save dcortesnet/73eb4f1e197fb86879a15e31ac289373 to your computer and use it in GitHub Desktop.
Save dcortesnet/73eb4f1e197fb86879a15e31ac289373 to your computer and use it in GitHub Desktop.
Nodejs lectura de archivo asíncono txt
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