You could use push() method with forEach() var dataset = [] d3.csv('elex.csv', function(data) { data.forEach(function(d) { dataset.push( [+d["CONUM"], +d["PIXPMK"]], [+d["CONUM"], +d["PIXMAR"]] ) }) })
JSON.stringify(dataset) "[[1,461],[1,436],[2,398],[2,428],[3,447],[3,436]]" However, you may want to use http://stackoverflow.com/ for code related question, has wider audience. Regards, Pratap On Thursday, May 26, 2016 at 7:51:24 PM UTC+5:30, Kuhu Gupta wrote: > > My elex.csv is in this format- > > "CONUM",PIXPMK","PIXMAR > > "1","461","436" "2","398","428", "3","447","436" I want my dataset in this > format- > > var dataset1 = [ [1, 417], [1, 436], [2, 398], [2, 428], [3, 447], [3, > 436]]; > > I have tried several times to get the fetch the data from csv in this form > but all in vain.please help me out.I am attaching my code- > > var dataset1 = []; > > d3.csv("elex.csv", function(data) { dataset1 = data.map(function(d) { > return [ [+d["CONUM"], +d["PIXMAR"]],[+d["CONUM"],+d["PIXPMK"]]]; }); > console.log(dataset1) }); > > this returns me dataset1 as [[[1,417],[1,436]],[[2,398],[2,428]]] -- Datameet is a community of Data Science enthusiasts in India. Know more about us by visiting http://datameet.org --- You received this message because you are subscribed to the Google Groups "datameet" group. To unsubscribe from this group and stop receiving emails from it, send an email to datameet+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.