Skip to content

Instantly share code, notes, and snippets.

@scottleedavis
Last active June 14, 2018 00:22
Show Gist options
  • Save scottleedavis/643001a6de9a3d1c322d92997ce2edb5 to your computer and use it in GitHub Desktop.
Save scottleedavis/643001a6de9a3d1c322d92997ce2edb5 to your computer and use it in GitHub Desktop.
extracts the rankData object to csv on the socialmobilityindex website
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