I have a csv file with 5000 rows, with thirty fields per row (The data represent measurements of the concentration of different chemical elements).
I want to parse and visualize the data with D3js. After reading in the file I have an array with length 5000. Here, each element is an object with the measurements of the various chemical elements. measurements[5].Aluminium
for instance returns the concentration of Aluminium at the fifth measurement.
Now I rather want to have arrays for each element with all their very measurments as elements. While this is easy with a for-loop, I want to try the map function.
Aluminium = measurements.map(function(row){
return row.Aluminium;
});
This works and I could do this for each element but I would prefer to have the element as a parameter itself.
function selectElement(elementname){
measurements.map(function(row){
return row.elementname;
});
};
Aluminium = selectElement('Aluminium');
Iron = selectElement('Iron');
And this is where I am stuck.