From c4bd28a1e265914ac52ae9f6858515d9ef292518 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 10 Feb 2016 16:59:19 -0500 Subject: [PATCH] JBAS-984 Student importer uses kcls addr normalizer Signed-off-by: Bill Erickson --- .../import_students/generate-patrons-from-csv.pl | 40 +++------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl b/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl index 534d82112a..4ad9e85b48 100755 --- a/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl +++ b/KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl @@ -8,6 +8,7 @@ use Data::Dumper; use Getopt::Long; use DateTime; use Sys::Syslog qw(syslog openlog); +use OpenILS::Utils::KCLSNormalize; # globals -- my $syslog_facility = 'LOCAL6'; # matches Evergreen gateway @@ -420,42 +421,9 @@ sub translate_patron_fields { $phash->{$_} = uc($phash->{$_}) if $phash->{$_}; } - # Replace 'AV' with 'AVE', but only when "AV" is surrounded by space - # period, or end of line, so as not to clobber names that contain AV. - if (my $s1 = $phash->{street1}) { - $s1 =~ s/\s+AV(\s|\.|$)+/ AVE /g; - $s1 =~ s/(^\s*|\s*$)//g; - $phash->{street1} = $s1; - } - - # Our policy is to include the apartment / unit number in the - # stree1 value. If street2 starts with APT or UNIT, append it - # onto the end of street1 (and clear street2). - # We also replace any occurrence of APT or UNIT with a '#'. - if (my $s2 = $phash->{street2}) { - if ($s2 =~ /^(APT|UNIT|#)/) { - $s2 =~ s/^(APT\.?|UNIT\.?)//g; # remove APT / UNIT - $s2 =~ s/^\s*//g; # trim leading space - if ($s2 =~ /^#/) { - # if the addr starts with a #, ensure it's followed by a space - $s2 =~ s/^#/# /g if $s2 =~ /^#[^\s]/; - } else { - # if no '#' is present to replace APT/UNIT, add it. - $s2 = "# $s2" unless $s2 =~ /^#/; - } - - # remove random "," "." "-" and extra spaces that - # occur after the initial "#". - $s2 =~ s/^#[\s,\.-]*(.*)$/# $1/g; - - if ($phash->{street1}) { - $phash->{street1} .= " $s2"; - } else { - $phash->{street1} = $s2; - } - $phash->{street2} = undef; - } - } + ($phash->{street1}, $phash->{street2}) = + OpenILS::Utils::KCLSNormalize::normalize_address_street( + $phash->{street1}, $phash->{street2}); # set required-but-missing address fields to NONE for my $field (qw/street1 city post_code/) { -- 2.11.0