I'm using d3 to import a CSV file for data visulisation. My CSV file has header rows that I need to convert to dates, and data that needs to be converted to integers:
ISBN,2019-08,2019-09,2019-10
9782749205465,107,488,218
9789423069313,95,87,186
I can import the CSV file and parse the data as integers using:
d3.csv("/assets/2019-20-download-stats.csv").then(function (data) {
data.forEach(function(d) {
d.ISBN = +d.ISBN;
d['201908'] = +d['201908'];
d['201909'] = +d['201909'];
d['201910'] = +d['201910'];
});
});
but the header rows are all strings in the output array, e.g.:
{
"201908": 107,
"201909": 488,
"201910": 218,
"ISBN": 9782749205465,
}
How do I format the header rows when importing the data?