score:1

since you're using d3 v5, the pattern described in that answer (which is 6 years old) doesn't work anymore: unlike previous versions, which used xmlhttprequest, the new version uses promises.

that alone qualifies your question as a duplicate. however, i'm writing this answer because there is an important piece of code missing in your question: the piece that adds the header row.

so, since this is v5, this is the pattern you have to use:

d3.text("data.csv").then(function(data){
    //....
})

inside the callback, you have to add the first row:

data = "foo,bar,baz\n" + data;

then, you can parse it, using d3.csvparse:

var newdata = d3.csvparse(data);

because we can't use d3.text in the s.o. snippet, here is a bl.ocks with the demo: https://bl.ocks.org/gerardofurtado/8849016b91b41ae463408c747417af95/8b299a22639621ae7619628a5b10fb9257783b8d


Related Query

More Query from same tag