-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from codeforIATI/sector-cofog-mapping
Add DAC sector / COFOG mapping
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |