Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3 replacing semicolon with comma

Hoping someone way clever than me can quickly help solve this. I have csv files coming in with a semicolon seperator. it cant read the headings:

d3.csv("file.csv", function(error, data) {
   data.forEach(function(d) {
       d.date = parseDate(d.date);
       d.value2 = +d.value2;
       d.value1 = +d.value1;
   });

I've tried adding something like data.replace(/\s*;\s*/g, ",") but doesnt work.

Appreciate the help.

like image 737
KornholioBeavis Avatar asked Dec 11 '14 10:12

KornholioBeavis


1 Answers

Let's convert my comment to an answer, so it's not left unanswered:

Assuming that your values are separated by a semicolon (so technically it's not a CSV anymore), you might want to look at this: https://github.com/d3/d3-dsv

like image 194
Pinguin Dirk Avatar answered Oct 03 '22 16:10

Pinguin Dirk