function csvJSON(csv){

  	var lines=csv.split("\n");

  	var result = [];

  	var headers=lines[0].replace("\r", "").split(",");

  	for(var i=1;i<lines.length;i++){

	  	var obj = {};
	  	var currentline=lines[i].replace("\r", "").split(",");

	  	for(var j=0;j<headers.length;j++){
		  	obj[headers[j]] = currentline[j];
	  	}

	  	result.push(obj);

  	}
  
  	//return result; //JavaScript object
  	return result; //JSON
}
//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].replace("\r", "").split(",");
  	for(var i=1;i<lines.length;i++){
	  	var obj = {};
	  	var currentline=lines[i].replace("\r", "").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 ] . replace ( "\r" , "" ) . split ( "," ) ; for ( var i = 1 ; i < lines . length ; i ++ ) { var obj = { } ; var currentline = lines [ i ] . replace ( "\r" , "" ) . 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
//return result; //JavaScript object //JSON