我有csv file
的标头是 Station ID
, Elev
, Latitude
, Longitude
, County
, Nat_ID
, Year_Built
, Capacity
, YrsStr1
, YrsStr2
, .....在这里,我想获取从YrsStr1
到YrsSt578
的所有列的值,并跳过其他列值。下面是跳过列的代码,但我无法获取列值?
var hd = d3.keys(res[0]);
for (var i = hd.length - 1; i >= 0; i--) {
if( (hd[i] === "Station") || (hd[i] === "ID") || (hd[i] === "Elev") || (hd[i] === "Latitude")
|| (hd[i] === "Longitude") || (hd[i] === "County") || (hd[i] === "Nat_ID") || (hd[i] === "Year_Built")
|| (hd[i] === "Capacity")){
}else{
}
}
使用
if(hd[i].include("YrsStr")){
供参考的代码笔网址http://codepen.io/nagasai/pen/pbyvmG
for (var i = hd.length - 1; i >= 0; i--) {
if(hd[i].includes("YrsStr")){
console.log("key"+hd[i] +"--value"+res[hd[i]]);
}