Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!