Last active
January 30, 2017 18:25
-
-
Save feload/37f94449b924b8f3483cd4f482c38230 to your computer and use it in GitHub Desktop.
This script allows you create a csv on the fly.
This file contains hidden or 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
var A = [['n','sqrt(n)']]; | |
for(var j=1; j<10; ++j){ | |
A.push([j, Math.sqrt(j)]); | |
} | |
var csvRows = []; | |
for(var i=0, l=A.length; i<l; ++i){ | |
csvRows.push(A[i].join(',')); | |
} | |
var csvString = csvRows.join("%0A"); | |
var a = document.createElement('a'); | |
a.href = 'data:attachment/csv,' + csvString; | |
a.target = '_blank'; | |
a.download = 'myFile.csv'; | |
document.body.appendChild(a); | |
a.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment