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

188
Views
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
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!