Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
Last active May 22, 2018 09:24
Show Gist options
  • Save kalinchernev/e87d22bec54275fa4b423f6e6ba4f7fb to your computer and use it in GitHub Desktop.
Save kalinchernev/e87d22bec54275fa4b423f6e6ba4f7fb to your computer and use it in GitHub Desktop.
Download the script and run it with `node getDataFromIATI.js`
const http = require("http");
const fs = require("fs");
const path = require("path");
const url =
"http://datastore.iatistandard.org/api/1/access/activity.csv?reporting-org=XI-IATI-EC_NEAR|XI-IATI-EC_DEVCO|XI-IATI-EC_FPI|XI-IATI-EC_ECHO&stream=True";
http
.get(url, resp => {
let data = "";
// A chunk of data has been recieved.
resp.on("data", chunk => {
data += chunk;
});
resp.on("end", () => {
console.log("IATI data downloaded in file activity.csv");
fs.writeFileSync(path.resolve("activity.csv"), data);
});
})
.on("error", err => {
console.log("Error: " + err.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment