1

I have two .csv files like that example:

date,type,brand,model,price
2014-11-27,  electric, tesla, model s , 100000
2014-11-27,  diesel, bmw, m3, 90000 
2014-12-13,  hybrid, toyota, yaris , 20000

How can I merge these files for make only one object?

Two files has the first row with names of columns, it's possible to delete? Or add it if I get the files without that first row?

2

1 Answer 1

1

try this:It will solve your problem.

 $(document).ready(function () {
    var newArray = [];
    d3.csv("test.csv", function(error, data) {// with header..
        data.forEach(function(d) {


                newArray.push(d);
        });

        });

        d3.csv("test1.csv", function(error, data2) {// without header..
            data2.forEach(function(d2) {


                    newArray.push(d2);
            });

            });
        console.log(newArray);
    });

for info see here:http://www.d3noob.org/2014/02/how-to-import-data-from-csv-file-with.html

Sign up to request clarification or add additional context in comments.

2 Comments

@Lins if you are using header in second file also then skip it in foreach for first time in second d3.csv.
Thank you @suchit for your help. Finally I got the response in that question: stackoverflow.com/questions/27041758/… for merge two files without header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.