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

149
Visualizações
JavaScript hebrew CSV parsing issue

so i got a csv file saves as CSV -UTF-8 file from excel on the right its in visual studio on the left its in excel.

when im trying to parse with PapaParse/csv-parser, i still see the output in <?> format which it means encoding : PapaParse try:

 papa.parse(file, {
    worker: true, 
    step: function (result) {
       count++; 
       console.log(result.data[0])
    },
    complete: function (results, file) {//
       console.log('parsing complete read', count, 'records.');
    }
});

csv-reader try:

const csv = require('csv-parser');
const results = [];
fs.createReadStream('Cities.csv')
   .pipe(csv())
   .on('data', function (datarow) {
       results.push(datarow);
   })
   .on('end', function () {
       console.log(results.toString('utf-8");
   });

In both situations the output is in <?> cant read hebrew chars

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

0

Looks to me like you're piping the raw chunk buffers to csv, not the result of converting to string using UTF-8 encoding. You aren't telling createReadStream to handle any encoding work for you, so it will read raw data and pass them to the csv function (since you're piping to it) as Buffer instances.

Rather than reading raw data and converting afterward, tell createReadStream you want it to handle conversion for you via its options parameter:

const csv = require('csv-parser');
const results = [];
fs.createReadStream('Cities.csv', 'utf-8')
// −−−−−−−−−−−−−−−−−−−−−−−−−−−−−^^^^^^^^^
   .pipe(csv())
   .on('data', function (datarow) {
       results.push(datarow);
   })
   .on('end', function () {
       // Use `results` here (it's an array of objects according to the
       // csv-parser documentation; calling `toString` on it probably isn't
       // what you want)
   });
about 4 years ago · Juan Pablo Isaza Relatório

0

You can try to add this:

format:"UTF-8"

   papa.parse(file, {
        worker: true, 
        step: function (result) {
           count++; 
           console.log(result.data[0])
        },
       format: "UTF-8"
        complete: function (results, file) {//
           console.log('parsing complete read', count, 'records.');
        }
    });
about 4 years ago · Juan Pablo Isaza Relatório

0

The problem was not because of the code, but because of the console properties. I had to change the font so that the console can display the Hebrew letters correctly.

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