0

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...

1 Answer 1

1

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];
  });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.