Search code examples
javascriptpapaparse

How can I download CSV data from variable to a csv file?


I am using papa parse library. It helped me in converting JSON to CSV but how can I download the same data into a excel file. My data is huge


Solution

  • If I'm understanding your question correctly, you have a CSV file which you now want to tell the browser to download? Have you looked at https://github.com/eligrey/FileSaver.js/ ? Allows you to tell the browser to download a wide variety of files.

    An example in using it:

    var blob = new Blob(myBigCSVFile, {type: "text/csv;charset=utf-8"});
    saveAs(blob, "file.csv");
    

    The browser, upon reaching the saveAs function will download the file you specified.