从D3多个CSV文件导入数据 [英] Importing data from multiple csv files in D3

查看:298
本文介绍了从D3多个CSV文件导入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是全新的,以D3和刚刚开始的一个项目。我的问题是这样的。
我想从2 CSV文件导入数据D3使用它们图形比较。我所面临的问题是:

1.How做我从多个CSV文件导入数据。结果
2.可我使用一个阵列的每个CSV或不D3只能使用一个全局数据数组?结果
 3.Is有没有办法选择从CSV文件中某列导入?结果
结果下面是一个例子,我想导入每个文件的oldVer在单独的数组,然后用2阵列的工作。在D3以及如何更多钞票?

I am brand new to D3 and just started working on an a project. My question is this. I want to import data from 2 csv files in D3 to use them for graph comparisons. The problems I am facing are:

1.How do I import data from multiple csv files.
2.Can I use one array for each csv or does D3 use only one global data array?
3.Is there a way to choose a certain column from the csv files to import?

Here is an example, I want to import the "oldVer" from each of the files in separate arrays and then use the 2 arrays to work with. Is that posible in D3 and how?

1的CSV结果
时间,oldVer,newVer,oldT,蝾螈结果
1,180930,190394,24,59结果
2,198039,159094,26,45结果
3,152581,194032,22,61结果

csv 1
time,oldVer,newVer,oldT,newT
1,180930,190394,24,59
2,198039,159094,26,45
3,152581,194032,22,61

2的CSV结果
时间,oldVer,newVer,oldT,蝾螈结果
1,184950,180435,27,26结果
2,120590,129409,13,13结果
3,165222,182133,60,54结果

csv 2
time,oldVer,newVer,oldT,newT
1,184950,180435,27,26
2,120590,129409,13,13
3,165222,182133,60,54

为愚蠢的问题,再次抱歉,但我发现在这个问题上有点反馈。任何帮助将AP preciated。

Again sorry for the dumb question but I have found little feedback on this matter. Any help will be appreciated.

推荐答案

您只需拨打 d3.csv 几次:

d3.csv("csv1.csv", function(error1, data1) {
  d3.csv("csv2.csv", function(error2, data2) {
    // do something with the data
  });
});

至于你的第三个问题,没有,D3将解析一切。没有什么强迫你使用,虽然所有的数据的,因此,如果您感兴趣的只有一列,刚刚从使用的数据。

As for your third question, no, D3 will parse everything. There's nothing forcing you to use all the data though, so if you're interested in only one column, just use the data from that.

这篇关于从D3多个CSV文件导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆