Skip to content

Commit

Permalink
testing handling spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgreen-moj committed Dec 28, 2023
1 parent cf59efc commit 7982f32
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import csv
from geocode import geocode, find_timezone, find_country_code

def clean_csv_rows_by_removing_nbsp(unformatted_csv_rows):
for data_dict in unformatted_csv_rows:
for key in data_dict:
cleaned_key = key.replace('\xa0', ' ')

data_dict[cleaned_key] = data_dict.pop(key)

return unformatted_csv_rows

# Convert CSV file to JSON object.
def convert_csv_to_json(file_path):
Expand Down Expand Up @@ -48,6 +56,8 @@ def add_geocoding_to_json(data):
# Convert CSV to valid JSON
json_data_without_geocoding = convert_csv_to_json(csv_file_path)

clean_json_data_without_geocoding = clean_csv_rows_by_removing_nbsp(json_data_without_geocoding)

json_data_with_geocoding = add_geocoding_to_json(
json_data_without_geocoding)

Expand Down

0 comments on commit 7982f32

Please sign in to comment.