Reputation: 31
How to add data to the first column of a CSV file containing 3 columns and 2000 rows? The data is an array containing sequential number that I have generated using JavaScript. I'm trying to load this external CSV file using D3js.
The JavaScript for the sequential number generation:
var time = [];
for (var i = 1; i != 2000; ++i){
time.push(i);
}
My CSV file should look something like this:
time,rate1,rate2,rate3
1,34,43,11
2,65,31,00
3,56,76,32
4,23,44,98
5,...
6,...
7,...
8,...
Thanks in advance...
Upvotes: 0
Views: 475
Reputation: 109242
You can add this when you go through the CSV data:
d3.csv("something.csv", function(error, data) {
data.forEach(function(d, i) {
d.time = time[i];
});
});
Upvotes: 1