Add a header line to explain the fields
[migration-tools.git] / unicorn / unicorn_patrons_to_tsv.pl
index 640bed2..ca0d8f0 100755 (executable)
@@ -125,7 +125,7 @@ for (my $u = 0; $u < @records; $u++) {
                }
                $records[$u]{'l_' . $a . '_std_line1'} = $records[$u]{'USER_' . uc($a) . '.STREET'};
                $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*)(.*)$/)) {
+               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'} = $3;
                }
@@ -205,8 +205,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}) {