Accepted answer

You can use a temporary variable for the new/current record. Your example also looks like you do not want an array (with gaps) but a map. Here is how I would load the data:

var authorMap = {}

var loadCSV = function(file){
    d3.csv(file, function(error, data) {
        data.forEach(function(d) {
            var a = authorMap[d.record_id] = {}
            a.record_id = d.record_id
            a.role      = d.role


Related Query

More Query from same tag