Skip to content

Instantly share code, notes, and snippets.

@swingley
Last active December 21, 2016 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swingley/93570e8db705c87b5687dc72c9ab1e15 to your computer and use it in GitHub Desktop.
Save swingley/93570e8db705c87b5687dc72c9ab1e15 to your computer and use it in GitHub Desktop.
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function(e) { window.vaData = e.target.response; });
xhr.open('get', 'data/68.json');
xhr.send();
vaData = JSON.parse(vaData);
vaData.table_data.values.forEach(function(row) { row.forEach(function(d, dIndex) { if ( d.indexOf && d.indexOf(',') > -1 ) { row[dIndex] = '"' + d + '"'; } }) });
var rows = vaData.table_data.values.map(function(row) { return row.join(','); });
copy(vaData.table_data.fields.join(','));
// paste to gist
copy(rows.join('\n'));
// paste to gist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment