mygames/mygames.js
//var csv is the CSV file with headers
var csv is the CSV file with headers
var csv is the CSV file with headers
function csvJSON(csv){
    var lines=csv.split("\n");
    var result = [];
    var headers=lines[0].toString().trim().split(",");
    for(var i=1;i<lines.length;i++){
        var obj = {};
        var currentline=lines[i].split(",");
        for(var j=0;j<headers.length;j++){
            obj[headers[j]] = currentline[j];
        }
        result.push(obj);
    }
    return result; 
}
function csvJSON ( csv ) { var lines = csv . split ( "\n" ) ; var result = [ ] ; var headers = lines [ 0 ] . toString ( ) . trim ( ) . split ( "," ) ; for ( var i = 1 ; i < lines . length ; i ++ ) { var obj = { } ; var currentline = lines [ i ] . split ( "," ) ; for ( var j = 0 ; j < headers . length ; j ++ ) { obj [ headers [ j ] ] = currentline [ j ] ; } result . push ( obj ) ; } return result ; }
var csv is the CSV file with headers
var csv is the CSV file with headers
//http://techslides.com/convert-csv-to-json-in-javascript //JavaScript object //return JSON.stringify(result); //JSON