Closed hhzl closed 7 years ago
var result = Papa.parse(data,{ dynamicTyping: true, encoding: 'utf8', skipEmptyLines: true }); if(result.errors.length == 0){ // result.data is array of arrays // row with index 0 is header var arrayOfObjects = []; var propertyName; for(var j = 1; j < result.data.length; j++){ var obj = {}; for(var k = 0; k < result.data[0].length; k++){ if(k < result.data[j].length){ propertyName = result.data[0][k]; obj[propertyName] = result.data[j][k]; } } arrayOfObjects.push(obj); }