Skip to content

Commit

Permalink
set UTF8 encodeing
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Penman authored and Richard Penman committed Jun 6, 2024
1 parent 3bdc4f0 commit 7571a0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 148,834 deletions.
6 changes: 3 additions & 3 deletions reverse_geocode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def rel_path(filename):
def __load_countries(self, country_filename):
"""Load a map of country code to name"""
self.__countries = {}
with open(country_filename, "r") as handler:
with open(country_filename, "r", encoding="utf-8") as handler:
for code, name in csv.reader(handler):
self.__countries[code] = name

Expand Down Expand Up @@ -95,7 +95,7 @@ def __extract(self, local_filename):
"""
if os.path.exists(local_filename):
# open compact JSON
rows = json.load(open(local_filename, "r"))
rows = json.load(open(local_filename, "r", encoding="utf-8"))
else:
geocode_reader, state_code_map = self.__download_geocode()

Expand All @@ -109,7 +109,7 @@ def __extract(self, local_filename):
state = state_code_map.get(row[8] + '.' + row[10])
row = latitude, longitude, country_code, city, state
rows.append(row)
json.dump(rows, open(local_filename, "w"))
json.dump(rows, open(local_filename, "w", encoding="utf-8"))

# load a list of known coordinates and corresponding __locations
coordinates, __locations = [], []
Expand Down
Loading

0 comments on commit 7571a0c

Please sign in to comment.