A question on "Data from the World Bank"


#1

Author: Patrick Li

I try the following code:

import sys
from pylab import *
import matplotlib.pyplot as plt
from pandas.io.excel import ExcelFile

if sys.version_info[0] == 2:
    from urllib import urlretrieve
elif sys.version_info[0] == 3:
    from urllib.request import urlretrieve

# == Get data and read into file gd.xls == #    
wb_data_file_dir = "http://api.worldbank.org/datafiles/"
file_name = "GC.DOD.TOTL.GD.ZS_Indicator_MetaData_en_EXCEL.xls"
url = wb_data_file_dir + file_name
try:
    urlretrieve(url, "gd.xls")
except Exception as inst:
    print(type(inst))
    print(inst.args)
    print(inst)

It gives the error message: 
<class 'urllib.error.HTTPError'>
()
HTTP Error 404: Not Found

It seems a failure at the link to the data file in world bank?


#2

Thanks Patrick. I just tested this with the latest version from the lecture on the website and it’s broken, just as you say. We’ll get it fixed ASAP.

I appreciate you letting us know!

John.