codeforIATI / iatikit

🐨 A toolkit for using IATI data
https://iatikit.readthedocs.io
MIT License
6 stars 0 forks source link

Add improved sector support #22

Closed andylolz closed 5 years ago

andylolz commented 5 years ago

Here’s a demo:

import pyandi

sector = pyandi.codelists().get('Sector').get(12230)  # "Basic health infrastructure"
pyandi.data().activities.find(sector=sector).sector

# [('12230', '1', '15'), ('12220', '1', '15'), ('12240', '1', '15'), ('13020', '1', '15'), ('14030', '1', '10'), ('72050', '1', '10'), ('52010', '1', '10'), ('16015', '1', '10')]

The output is currently a tuple of (code, vocabulary, percentage). This probably needs to be turned into a Sector model.

andylolz commented 5 years ago

Changed a bit:

import pyandi

sector = pyandi.sector(12230, 1)  # "Basic health infrastructure"
pyandi.data().activities.find(sector=sector).sector

# [<Sector (Basic health infrastructure (12230), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Basic health care (12220), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Basic nutrition (12240), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Reproductive health care (13020), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Basic drinking water supply and basic sanitation (14030), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Relief co-ordination; protection and support services (72050), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Food aid/Food security programmes (52010), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>, <Sector (Social services (incl youth development and women+ children) (16015), Vocabulary: OECD DAC CRS Purpose Codes (5 digit))>]