I need to write all values from a specific column in a .csv file to an array.
Please execute the following working example and notice, that all the values from the column Address are successfully written into the array variable tmpArr
var csvString= "Address,longitude,latitude,geometry\n"+
"1,2,3,4\n5,6,7,8\n2,3,4,5\n6,7,8,9";
var t = d3.csv.parse(csvString);
var tmpArr = t.map(function(d){return d.Address;});
console.log(tmpArr);
<script src="https://d3js.org/d3.v3.min.js"></script>
But how can I load a .csv file into the variable csvString instead of a hardcoded string?
I successfully load the .csv file via ajax, but I only get the output ,,,
csvToChart("daten/kundenimporte/", "test.csv");
function csvToChart(basepath, filename)
{
$.ajax({
url: basepath + filename,
method: "GET",
success: myCallback
});
}
function myCallback(response)
{
var t = d3.csv.parse(response);
d3.select("#output").html(
t.map(function(d){
return d.Kundengruppe;
})
);
}
I get ReferenceError: d is not defined.
How can I successfully load my .csv file?