0

My data is in multiple CSV files with 2 columns, {timestamp,value}.

I want to load those multiple files (the number/names are not fixed but specified by other functions) and plot them together.

I know how to load multiple columns from one file, but I can't do this here.

What's the solution here ?

Thanks !

Salamandar
  • 589
  • 6
  • 16
  • Take a look at [this response](http://stackoverflow.com/a/34473349/3014679) to a similar question which avoids needing to nest callbacks. It does, however, require jQuery. – Ryan Lee Simms Jan 30 '17 at 20:19

1 Answers1

1

let's say you have two files fileA ans fileB You can load csv files in d3 using the code below

    var data = [];
    d3.csv(path_to_data, type, function(error,dataA) {
          if (error) throw error
     }
    d3.csv(path_to_data, type, function(error,dataB) {
          if (error) throw error
     }
     
     dataA.forEach(function(item) {
            data.push(item);
     }
     dataB.forEach(function(item) {
            data.push(item);
     }

and do the same for the other files and pass data var into your main function which renders the graph.

Maybe this might help you.

Deepak Sharma
  • 458
  • 9
  • 21