Skip to content

Commit

Permalink
Merge pull request #74 from codeforIATI/sector-cofog-mapping
Browse files Browse the repository at this point in the history
Add DAC sector / COFOG mapping
  • Loading branch information
markbrough authored Nov 8, 2023
2 parents f79e67b + bfc46da commit 8bd2713
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
repo: Unofficial-Codelists
- importer: reporting_organisation_group
repo: Unofficial-Codelists
- importer: sector_cofog
repo: Unofficial-Codelists
name: "Run importer: ${{ matrix.importer }}"
runs-on: ubuntu-latest
steps:
Expand Down
40 changes: 40 additions & 0 deletions importers/sector_cofog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import csv

from .helpers import Importer, fetch

def run():
url = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vTXYj1IPNYkdwf21XQSRTixGwAQRTJENERUSGRvYa_RILTIKjGQ6vlmr_nUNukXIRkjAY8TbJP6VK4g/pub?gid=711009742&single=true&output=csv'

r = fetch(url)
fieldnames = [
'',
'codeforiati:group-code',
'codeforiati:group-name_en',
'codeforiati:category-code',
'codeforiati:category-name_en',
'code',
'name_en',
'codeforiati:cofog-class',
'codeforiati:cofog-group',
'codeforiati:cofog-division',
'description_en'
]
reader = csv.DictReader(r.iter_lines(decode_unicode=True), fieldnames=fieldnames)
sectors_cofog = [row for i, row in enumerate(reader) if i > 2]
lookup = [
('code', 'code'),
('name_en', 'name_en'),
('codeforiati:category-code', 'codeforiati:category-code'),
('codeforiati:category-name_en', 'codeforiati:category-name_en'),
('codeforiati:group-code', 'codeforiati:group-code'),
('codeforiati:group-name_en', 'codeforiati:group-name_en'),
('codeforiati:cofog-class', 'codeforiati:cofog-class'),
('codeforiati:cofog-group', 'codeforiati:cofog-group'),
('codeforiati:cofog-division', 'codeforiati:cofog-division'),
('description_en', 'description_en')
]
Importer('SectorCOFOG', None, lookup, source_data=sectors_cofog, order_by='code/text()', sort_attrs=True)


if __name__ == '__main__':
run()
15 changes: 15 additions & 0 deletions templates/SectorCOFOG.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<codelist xmlns:codeforiati="https://codeforiati.org/" name="SectorCOFOG" xml:lang="en" complete="1" embedded="0">
<metadata>
<name>
<narrative>DAC Sector / COFOG</narrative>
</name>
<description>
<narrative>Mapping of DAC CRS Sector Codes against COFOG (Classification of the Functions of Government) codes.</narrative>
</description>
<url>https://docs.google.com/spreadsheets/d/1MXlJiJa33_lj9wZWYG2oGc8V3srkfYEReTsGD8P-OzY/edit#gid=711009742</url>
<category>
<narrative>Replicated</narrative>
</category>
</metadata>
<codelist-items/>
</codelist>

0 comments on commit 8bd2713

Please sign in to comment.