Wednesday, 9 September 2015

World Bank Indicators: collect and process them in Google Sheet

Hey guys!

I recently found myself in having to process some statistics data about countries performances...
Actually, I'm looking to expat and found this could be an interisting method for picking up a destination.

So what have I found?
World Bank is giving us loads of free data to play with, about countries:

  • GDP, 
  • electricity access, 
  • health,
  • education,
  • etc.

I thought: why don't load a bunch of these data in a sheet, set some filters and see what could be my best place to be?

So here we go, you can download it here: https://docs.google.com/spreadsheets/d/1TyI-98fVfl1BsVGM0t6b6V65WysPulW8Z2zUsYTul04

Follow the instructions on the spreadsheet.

One suggestion: the command inside the sheet for loading indicators will load about 13-15 thousands of them!!!
Use the World Bank web page for finding indicators could be easier: http://data.worldbank.org/
It must be the last bit of an indicator web link, i.e. for GDP
Web link: http://data.worldbank.org/indicator/NY.GDP.MKTP.CD
Indicator: NY.GDP.MKTP.CD

Authorization are for running some Google Apps Script code.
If you are interested in the code, follow this link: http://pavatechpit.blogspot.it/2015/09/world-bank-xml-service-and-google-apps.html

Also, don't forget World Bank data is available on the Google Public Data Explorer project: http://www.google.com/publicdata/explore?ds=d5bncppjof8f9_&hl=en&dl=en

World Bank XML service and Google Apps Script

Hi guys!

Easy task also for a novice as me in Google scripting, I wrote 200 lines in one day for ripping some data from the World Bank XML API service and presenting it in a Google Sheet.

Here the sheet: https://docs.google.com/spreadsheets/d/1TyI-98fVfl1BsVGM0t6b6V65WysPulW8Z2zUsYTul04

Functions are:
  • onOpen() : creates a menu in Google Sheet for launching the functions
  • average() : average function which supports NULL values, get it here - couldn't find any better on the web
  • loadDataXml(): given an indicator, fetch XML and process in such a way to export it both as a custom function or from a menu command
  • getData(): menu command for loadDataXml()
  • loadIndicatorsXml (): menu command for fetching indicators list as XML in a new sheet

loadDataXml()
Given an indicator, fetch XML and process in such a way to export it both as a custom function or from a menu command
getData()
Menu command for loadDataXml()
loadIndicatorsXml ()
Menu command for fetching indicators list as XML in a new sheet
onOpen()
 Creates a menu in Google Sheet for launching the functions

Javascript: average which accept null values

Pretty easy!

https://gist.github.com/mrenrich84/571cf7e5ebbaa777af1e