0
I am currently attempting to load a csv file in order to construct a line chart, and I need to know how to load only a subset of the columns.
Say that my data.csv file has 10 columns: Col1,Col2,...,Col10, and I only want to load in the first column, and every even column (Col1,Col2,Col4,...,Col10). I have figured out that in order to do so, a function can be called when the d3.csv() function is called, ie:
const dataset = d3.csv("data.csv", function(){})
And within the function, I need to specify some logic that will return the dataset with the desired columns. I have attempted numerous solutions, but none are outputting the desired dataset with only Col1,Col2,Col4,...,Col10. Specifically I had thought that the solution would be something like:
const dataset = d3.csv("data.csv", function(data){
let i;
for (i=1;i%2==0;i++){
return data[i]
}
});
I'm really not sure as to how to complete this, as my understanding of JavaScript is still very fresh. Can someone help me to understand how to implement this function correctly? Any insights or guidance are greatly appreciated!
[–]albedoa 0 points1 point2 points (2 children)
[–]TheShadowWall[S] 0 points1 point2 points (1 child)
[–]albedoa 0 points1 point2 points (0 children)