Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

415
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda