Skip to content

Instantly share code, notes, and snippets.

@hvianna
Created January 31, 2020 12:40
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 hvianna/cb42092465805308304e14443b93ca8f to your computer and use it in GitHub Desktop.
Save hvianna/cb42092465805308304e14443b93ca8f to your computer and use it in GitHub Desktop.
Ler arquivo texto linha a linha com node.js
// https://nodejs.org/api/readline.html#readline_example_read_file_stream_line_by_line
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: fs.createReadStream('arquivo.tsv'),
crlfDelay: Infinity
});
rl.on('line', linha => {
let campos = linha.split('\t'); // campos delimitados por tab
console.log( `Inscrição: ${campos[1]} - Evento: ${campos[2]} - Nome: ${campos[0]}` );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment