Last active
May 22, 2018 09:24
-
-
Save kalinchernev/e87d22bec54275fa4b423f6e6ba4f7fb to your computer and use it in GitHub Desktop.
Download the script and run it with `node getDataFromIATI.js`
This file contains hidden or 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
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