Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Last active December 19, 2015 03:28
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 mhkeller/5889916 to your computer and use it in GitHub Desktop.
Save mhkeller/5889916 to your computer and use it in GitHub Desktop.
Converting json to csv with dsv.js for treasury.io
var $ = require('jquery'),
dsv = require('dsv'),
pi_endpoint = 'https://premium.scraperwiki.com/cc7znvq/47d80ae900e04f2/sql/?q=';
function convertJSONtoCSV(query){
fetchJSON(query).done(function(json){
$download_csv_btn.html('Download .csv')
// This line does all of the json to csv conversion
var csv = dsv.csv.format(json);
console.log(csv)
});
};
function fetchJSON(query){
return $.ajax({
url: api_endpoint + query
});
};
@matherton
Copy link

Hi how do you require dvs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment