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

193
Visualizações
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 à 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