Skip to content

Commit

Permalink
fix utf encoding on geography.py (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezmorales authored Nov 9, 2023
1 parent a251463 commit f34efbf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/un/sdg/geography.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_sdg2type(file):
Map of SDG code -> SDG type.
'''
sdg2type = {}
with open(file) as f:
with open(file, encoding='utf-8') as f:
reader = csv.DictReader(f)
for row in reader:
sdg2type[row['GEOGRAPHY_CODE']] = row['GEOGRAPHY_TYPE']
Expand Down Expand Up @@ -140,7 +140,7 @@ def get_un2dc_curated(file):
Map of UN code -> curated Node.
'''
un2dc_curated = {}
with open(file) as f:
with open(file, encoding='utf-8') as f:
reader = csv.DictReader(f)
for row in reader:

Expand Down Expand Up @@ -204,8 +204,8 @@ def write_un_places(input_geos, output, sdg2type, un2sdg, un2dc_curated):
'''
un2dc_generated = {}
new_subjects = []
with open(input_geos) as f_in:
with open(output, 'w') as f_out:
with open(input_geos, encoding='utf-8') as f_in:
with open(output, 'w', encoding='utf-8') as f_out:
reader = csv.DictReader(f_in)
for row in reader:
subject = row['subject_id']
Expand Down Expand Up @@ -288,7 +288,7 @@ def write_un_containment(output, containment, new_subjects):
new_subjects: List of Nodes for new places.
'''
with open(output, 'w') as f:
with open(output, 'w', encoding='utf-8') as f:
for s in sorted(containment):
c = ''
for o in containment[s]:
Expand Down Expand Up @@ -323,7 +323,7 @@ def write_place_mappings(output, sdg2un, un2dc_curated, un2dc_generated):
un2dc_curated: Map of UN code -> curated Node.
un2dc_generated: Map of UN code -> generated Node.
'''
with open(output, 'w') as f:
with open(output, 'w', encoding='utf-8') as f:
writer = csv.DictWriter(f, fieldnames=['sdg', 'dcid'])
writer.writeheader()
for code in sorted(sdg2un):
Expand Down

0 comments on commit f34efbf

Please sign in to comment.