Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

360
Visualizações
How to split a line with tab in Nodejs?

I have a file separated with tab:

04/20/13,22:54:08   10  17h ADC 10  11123456545644  0   

I wrote this snippet to read this file:

var lineReader = require('line-reader');
var fs = require('fs');

lineReader.eachLine('foo.txt', function(line, last, cb) {
      var splitLine = line.split('\t');
      console.log(splitLine[0]);

      if (last) {
            cb(false); // stop reading
      } else {
        cb();
      }
    });

The output is this:

04/20/13,22:54:08
10
17h ADC
10
11123456545644
0

How I can pick up the info separated?

For example: with splitLine(0) I'm expecting only the timeStamp, but it prints the entire row.

How is it possible?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

With the help of substring you can get the timestamp. console.log(splitLine[0].substring(10));

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda