Reputation: 648
What I want to do
My CSV looks like this
,,Name,First names,s,r,Nat,born,starting point,starting date,arrival date,days,km,Assist,Support,Style,note,arrival date 2
1,1,KAGGE,Erling,,,Nor,1/15/1963,Berkner Island,11/18/1992,1/7/1993,50,appr. 1300,n,n,solo,first solo unassisted,
2,2,ARNESEN,Liv,f,,Nor,6/1/1953,Hercules Inlet,11/4/1994,12/24/1994,50,1130,n,n,solo,first woman unassisted,
3,3,HAUGE,Odd Harald,,,Nor,1956,Berkner Island,11/4/1994,12/27/1994,54,appr. 1300,n,n,,,
How should I import my CSV so that I will be able to access data such as
.text(function(d) {
return d['starting point'];
});
What I've tried
I have tried nesting the data
d3.csv("data.csv", function(csv_data) {
var data = d3.nest()
.key(function(d) {
return d.Name;
})
.entries(csv_data)
console.log(data);
which in my console looks something like this:
0: Object
key: " DICKINSON"
values: Array[2]
0: Object
Assist: "n"
First names: "Conrad"
Name: " DICKINSON"
Nat: "UK"
starting point: "Hercules Inlet"
1:Object
2:Object
....
However I am only able to return d.key
.text(function(d) {
return d.key;
});
I have asked this question before with code examples but I think my question was too confusing. If anyone could help me get to my data I would be really grateful!
Upvotes: 0
Views: 83
Reputation: 3110
Don't nest it.
d3.csv("data.csv", function(csv_data) {
select("body")
.append("div")
.selectAll('p')
.data(csv_data)
.enter()
.append('p')
.text(function(d) { d.Name + ', ' + d.location...})
});
Upvotes: 1