gpt4 book ai didi

javascript - 读取 d3 键值

转载 作者:行者123 更新时间:2023-12-02 14:31:28 25 4
gpt4 key购买 nike

我有 csv 文件,其标题为 Station IDElevLatitudeLongitude, , Nat_ID, Year_Built, 容量, YrsStr1, YrsStr2,.....在这里,我想获取从 YrsStr1YrsSt578 的所有列的值,并跳过其他列值。下面是跳过列的代码,但我无法获取列值?

 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].includes("YrsStr")){

codepen 引用网址 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]]);
}

关于javascript - 读取 d3 键值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37771423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com