Count the number of rows of a CSV file, with d3.js

Posted by user2934073 on Stack Overflow See other posts from Stack Overflow or by user2934073
Published on 2013-10-31T15:52:09Z Indexed on 2013/10/31 15:53 UTC
Read the original article Hit count: 282

Filed under:
|

Suppose I have this CSV file

Day,What
2013-10-27,Apple
2013-10-27,Cake
2013-10-27,Apple
2013-10-28,Apple
2013-10-28,Apple
2013-10-28,Blueberry
2013-10-28,Orange

I would like to drawn with D3.js a time-series graph. All I need to do is to display the sum of the number of rows for each day. As an example, the 27 of November should have 3 as value, the 28th should have 4.

Is there a way I can archive it? I've been trying to create a new dataset out of the CSV one with no positive results.

var dataset;

d3.csv("data.csv", function(d) {
  return {
    Day: new Date(d.Day),
    What: d.What
  };
}, 

function(error, rows) {
    dataset = rows;
    // I SUPPOSE THE FUNCTION THAT GENERATE THE NEW DATASET SHOULD GO THERE     
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about d3.js