Created
January 31, 2020 12:40
-
-
Save hvianna/cb42092465805308304e14443b93ca8f to your computer and use it in GitHub Desktop.
Ler arquivo texto linha a linha com node.js
This file contains hidden or 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
// 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