From 3bdabd6886706d2b57cba78f6d3af0e4ee32d951 Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 17:45:14 +0100 Subject: [PATCH 1/4] Add importer for Sector/COFOG mapping codelist --- importers/sector_cofog.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 importers/sector_cofog.py diff --git a/importers/sector_cofog.py b/importers/sector_cofog.py new file mode 100644 index 0000000..a9a5216 --- /dev/null +++ b/importers/sector_cofog.py @@ -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() From d9995b6e573db658f8c135ab790105a3df902452 Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 17:45:32 +0100 Subject: [PATCH 2/4] Add Sector/COFOG mapping codelist template --- templates/SectorCOFOG.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 templates/SectorCOFOG.xml diff --git a/templates/SectorCOFOG.xml b/templates/SectorCOFOG.xml new file mode 100644 index 0000000..9171a54 --- /dev/null +++ b/templates/SectorCOFOG.xml @@ -0,0 +1,15 @@ + + + + DAC COFOG Mappings + + + Mapping of DAC CRS Sector Codes against COFOG (Classification of the Functions of Government) codes. + + https://docs.google.com/spreadsheets/d/1MXlJiJa33_lj9wZWYG2oGc8V3srkfYEReTsGD8P-OzY/edit#gid=711009742 + + Replicated + + + + From e186a428b2f3a2408d9a48284f27ac4ff3503db8 Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 17:46:18 +0100 Subject: [PATCH 3/4] Run Sector/COFOG mapping importer --- .github/workflows/import.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml index 0355eb6..9e983a2 100644 --- a/.github/workflows/import.yml +++ b/.github/workflows/import.yml @@ -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: From bfc46dab84f2791543eab1a89b4ea3359058761e Mon Sep 17 00:00:00 2001 From: Mark Brough Date: Wed, 8 Nov 2023 17:50:00 +0100 Subject: [PATCH 4/4] Update codelist name --- templates/SectorCOFOG.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/SectorCOFOG.xml b/templates/SectorCOFOG.xml index 9171a54..a309194 100644 --- a/templates/SectorCOFOG.xml +++ b/templates/SectorCOFOG.xml @@ -1,7 +1,7 @@ - DAC COFOG Mappings + DAC Sector / COFOG Mapping of DAC CRS Sector Codes against COFOG (Classification of the Functions of Government) codes.