Last active
June 14, 2018 00:22
-
-
Save scottleedavis/643001a6de9a3d1c322d92997ce2edb5 to your computer and use it in GitHub Desktop.
extracts the rankData object to csv on the socialmobilityindex website
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
var lineArray = []; | |
rankData.forEach(function (infoArray, index) { | |
infoArray = infoArray.map( (info) => { | |
if( typeof info === "string" ) | |
return info.replace(/,/g, "").replace(/\$/g, ""); | |
else | |
return info; | |
}); | |
var line = infoArray.join(","); | |
lineArray.push(line); | |
}); | |
var csvContent = lineArray.join("\n"); | |
document.querySelector('html').innerText = csvContent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment