I have a dictionary of currencies here in JSON
.
I will give a sample for simplicity:
{
"AED": "united Arab Emirates Dirham",
"AFN": "Afghan Afghani",
...
"ZWL": "Zimbabwean Dollar"
}
And I wish to add them to a file where i can continuously add different sets of currencies at different times. The file should have a column for the code name of currency (e.g. "AED") and another column for name.
I really don't know where to start. Help to point me in the right direction will be very much appreciated.
My code for the dictionary is as follows:
import json
import urllib.request
def _fetch_currencies():
f = urllib.request.urlopen(
'http://openexchangerates.org/api/currencies.json')
charset = f.info().get_param('charset', 'utf8')
data = f.read()
decoded = json.loads(data.decode(charset))
print(json.dumps(decoded, indent=4))