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

187
Visualizações
papaparse results not saving to variable in Node.js/electron

I'm trying to work with the output of a papaparse CSV read using the following:

const file = fs.createReadStream('./data.csv');
let out;
Papa.parse(file, {
  header: true,
  dynamicTyping: true,
  complete: (results) => {
    console.log(results);
    out = results.data;
  },
});

The console.log correctly log the results, but out remains undefined... I feel like I'm doing it very similar to this answer... any help much appreciated

Note: although this seems very similar to this question, I actually do need to persist the data into global state (not going to go into detail here)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Whelp... RTFM.

Papa Parse can also parse in a node streaming style which makes .pipe available. Simply pipe the Readable Stream to the stream returned from Papa.parse(Papa.NODE_STREAM_INPUT, options). The Papa.LocalChunkSize, Papa.RemoteChunkSize , download, withCredentials, worker, step, and complete config options are unavailable.

strange that the console log still runs... Anyway workaround solution:

const csvString = fs.readFileSync('./data.csv').toString();
let out;
Papa.parse(csvString, {
  header: true,
  dynamicTyping: true,
  complete: (results) => {
    console.log(results);
    out = results.data;
  },
});
about 4 years ago · Juan Pablo Isaza 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