From 6a152a786715e2db01dd2b5ab2b80286cabd954b Mon Sep 17 00:00:00 2001 From: Amy Mok Date: Wed, 3 Jan 2018 13:08:41 -0500 Subject: [PATCH] Create a normalize function --- .../management/commands/load_branch_locations.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mapusaurus/respondents/management/commands/load_branch_locations.py b/mapusaurus/respondents/management/commands/load_branch_locations.py index d8cb5f3b..20908bc0 100644 --- a/mapusaurus/respondents/management/commands/load_branch_locations.py +++ b/mapusaurus/respondents/management/commands/load_branch_locations.py @@ -5,6 +5,9 @@ class Command(BaseCommand): args = "" + def normalize(s): + return s.strip().upper() + def handle(self, *args, **options): branch_location_filename = args[0] count = 0; @@ -14,11 +17,11 @@ def handle(self, *args, **options): for branch_location_line in branch_location_reader: record = Branch( year = branch_location_line[0].replace("'", ""), - name = branch_location_line[6].strip().upper(), - street = branch_location_line[7].strip().upper() if branch_location_line[7] != '0' else '', - city = branch_location_line[8].strip().upper(), - state = branch_location_line[10].strip().upper(), - zipcode = branch_location_line[11].strip(), + name = normalize(branch_location_line[6]), + street = normalize(branch_location_line[7]) if branch_location_line[7] != '0' else '', + city = normalize(branch_location_line[8]), + state = normalize(branch_location_line[10]), + zipcode = normalize(branch_location_line[11]), lat = branch_location_line[13], lon = branch_location_line[12], )