X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=unicorn%2Funicorn_patrons_to_tsv.pl;h=636c21a3c75dd36d02bd7c3c9caf0abfd611309a;hp=1522d29dac24909fccfead700ffd3ab0d8c652fa;hb=a42d5301d03e7f7c424df4642a31125c09aeafa2;hpb=aac81ac0be521f41fb266c7af116b639f7e7f1b0 diff --git a/unicorn/unicorn_patrons_to_tsv.pl b/unicorn/unicorn_patrons_to_tsv.pl index 1522d29..636c21a 100755 --- a/unicorn/unicorn_patrons_to_tsv.pl +++ b/unicorn/unicorn_patrons_to_tsv.pl @@ -1,5 +1,21 @@ #!/usr/bin/perl -w +# Copyright 2009-2012, Equinox Software, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + # Converts a Unicorn users.data file to a tab-separated file. # 2009-08-10 Ben Ostrowsky @@ -124,9 +140,10 @@ for (my $u = 0; $u < @records; $u++) { $records[$u]{'l_' . $a . '_' . $f} = $records[$u]{uc('USER_' . $a . '.' . $f)}; } $records[$u]{'l_' . $a . '_std_line1'} = $records[$u]{'USER_' . uc($a) . '.STREET'}; - if ((defined $records[$u]{'USER_' . uc($a) . '.CITY/STATE'}) && ($records[$u]{'USER_' . uc($a) . '.CITY/STATE'} =~ m/^(.*), (.*)$/)) { + $records[$u]{'l_' . $a . '_std_line2'} = $records[$u]{'USER_' . uc($a) . '.LINE2'}; + if ((defined $records[$u]{'USER_' . uc($a) . '.CITY/STATE'}) && ($records[$u]{'USER_' . uc($a) . '.CITY/STATE'} =~ m/^(.*),?(\s+)(.*)$/)) { $records[$u]{'l_' . $a . '_std_city'} = $1; - $records[$u]{'l_' . $a . '_std_state'} = $2; + $records[$u]{'l_' . $a . '_std_state'} = $3; } $records[$u]{'l_' . $a . '_std_zip'} = $records[$u]{'USER_' . uc($a) . '.ZIP'}; @@ -204,8 +221,9 @@ for (my $u = 0; $u < @records; $u++) { } - # Print the results +print join("\t", @output_fields) . "\n"; + for (my $u = 0; $u < @records; $u++) { foreach $f (@output_fields) { if (defined $records[$u]{$f}) {