adding actor.usr_setting to production tables
[migration-tools.git] / unicorn / unicorn_patrons_to_tsv.pl
index 1522d29..636c21a 100755 (executable)
@@ -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 <ben@esilibrary.com>
 
@@ -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}) {