I need to import 8-10 CSV files into some JS code. Each file has about 8 different columns. I would like to store this information in an object (possibly identifying the object based on one of the ID fields). The problem is, the easiest way I can think of looks like this:
var authorArr = [];
d3.csv("data/authors.csv", function(csv) {
csv.forEach(function(d) {
authorArr[d.record_id] = [];
d.record_id = +d.record_id;
d.name = d.name
d.name_inverted = d.name_inverted;
d.role = d.role;
d.sequence = +d.sequence;
d.is_person = d.is_person;
authorArr[d.record_id] = d.name;
authorArr[d.record_id] = d.role;
etc...
Surely this cannot be the quickest way...Also, there are quite a bit of duplicated record_id values as well, so every time there is a repeat, I would lose all previous data with my horrible approach.
I'm not sure if that's enough detail. If not, I would be glad to add more.