Skip to content

Instantly share code, notes, and snippets.

@gavi
Created March 31, 2014 20:09
Show Gist options
  • Save gavi/9901086 to your computer and use it in GitHub Desktop.
Save gavi/9901086 to your computer and use it in GitHub Desktop.
Get Column names from csv data using D3
/*
As you read the data, use Object.keys() method to extract the column names. Might be useful for binding dropdowns.
*/
var columns=null;
d3.csv('nutdata.csv').row(function(row){
if(columns==null){
columns=Object.keys(row);
columns=columns.slice(2,48); //Optional - to remove columns you dont need
}
return {"name":row.Shrt_Desc}; // Do data manipulation here
})
.get(function(error,data){
console.log("Finished Getting Data");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment