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

413
Views
Read CSV File In React

I'm uploading and then reading the CSV file but I'm facing an issue while splitting it, so basically, column names in CSV contain ',' so when I'm going to split the columns with ',' so I don't get the full column value, please suggest me some proper way for it. Thanks

const readCsv = (file) => {
    const reader = new FileReader();
    const filetext = reader.readAsBinaryString(file);
    reader.addEventListener('load', function (e) {
        const data = e.target.result;
        let parsedata = [];

        let newLinebrk = data.split('\n');
        for (let i = 0; i < newLinebrk.length; i++) {
            parsedata.push(newLinebrk[i].split(','));
        }
        console.log("parsedData: ", parsedata);
    });
};

CSV:

column 1   column2                    
test       lorem, ipsum, dummy/text

after splitting:

['test', 'lorem', 'ipsum', 'dummy/text']

so by doing that I'm unable to get a proper column name that contains a comma in string.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In my case, I used Papa Parse which fulfills my all requirements.

const readCsv = (file) => {
    const reader = new FileReader();
    reader.readAsBinaryString(file);
    reader.addEventListener('load', function (e) {
        const data = e.target.result;
        Papaparse.parse(data, {
            complete: function (results) {
                console.log("results: ", results.data);
            },
        });
    });
};
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!