Created
March 10, 2020 04:01
-
-
Save Falciighol/174ed083bc95491a80b538b64eab24f0 to your computer and use it in GitHub Desktop.
[CSV from Array]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rows = [ | |
["name1", "city1", "some other info"], | |
["name2", "city2", "more info"] | |
]; | |
let csvContent = "data:text/csv;charset=utf-8," + rows.map(e => e.join(",")).join("\n"); | |
var encodedUri = encodeURI(csvContent); | |
var link = document.createElement("a"); | |
link.setAttribute("href", encodedUri); | |
link.setAttribute("download", "my_data.csv"); | |
document.body.appendChild(link); // Required for FF | |
link.click(); // This will download the data file named "my_data.csv". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment