Reputation: 449
I'm working with csv document that I import thanks to d3. Unfortunatelly, the parser is not allways the comma and I didn't find where the parser is recorded in the file architecture... anyway. Now, I know that my parser is a semicolon, then I've tried to use the dsv function like this
var csvfile= d3.dsv(";", VariableWithcsvFileInside);
but console.log(data);
return this :
function e(n,e,i){arguments.length<3&&(i=e,e=null);var a=Cn(n,t,null==e?r:u(e),i);return a.row=function(n){return arguments.length?a.response(null==(e=n)?r:u(n)):e},a}
Is there a script that I have to import or something I do wrong? Thanks for anwering.
PS : var csvfile = d3.csv.parse(VariableWithcsvFileInside);
works...
Upvotes: 1
Views: 2196
Reputation: 25157
Hard to tell what's happening, because you didn't include the code that loads and parses the data from a url, but this is how it should work:
// ssv is "Semicolon Separated Values" parser
var ssv = d3.dsv(";", "text/plain");
// Load and (later, asynchronously) parse the data
ssv(url, function(data) {
console.log(data); // should log an array of parsed values
});
If the data is already loaded and just needs to be parsed then the 2nd line becomes:
var data = ssv.parse(stringOfDataThatWasAlreadyLoaded);
console.log(data); // should log an array of parsed values
Upvotes: 4