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

189
Vistas
D3js: csv vs json reading. Differences when modifying data

I started learning D3js and there is one thing that I would like to understand.

Why can I transform data easly when reading in CSV, but not when I use json.

There it goes an example: I read csv from an API and then I parse to numeric one of the key:value of the object (that comes as string):

const urlData = "https://analisi.transparenciacatalunya.cat/resource/7xn6-46kz.csv?$where=any = 2018&$select=nom_sector,SUM(co2eq)&$group=nom_sector&$order=SUM(co2eq) DESC";

    const [data, setData] = React.useState(null);

    React.useEffect(() => {

        const row = (d) => {
            d.emision = +d['SUM_co2eq'];
            return d;
        }

        d3
            .csv(urlData, row)
            .then(setData)
    }, []);

The data can be read as JSON with the same structure, just changing 7xn6-46kz.csv to 7xn6-46kz.json and the reading method to json(). The structure is the same but the parsing-to-numeric logic doesn't work. Why is that? Any ideas??

about 4 years ago · Juan Pablo Isaza
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