]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/extras/import/barcode_lookup_loader.pl
updating the profile map
[Evergreen.git] / Evergreen / src / extras / import / barcode_lookup_loader.pl
1 #!/usr/bin/perl
2
3 use Getopt::Long;
4
5 my ($usermap,$nonusers,$recirc) = ();
6
7 GetOptions(
8         'usermap=s'        => \$usermap,
9         'nonusers=s'        => \$nonusers,
10         'recirc=s'        => \$recirc,
11 );
12
13 my %u_map;
14 open F, $usermap;
15 while (my $line = <F>) {
16         chomp($line);
17         my ($b,$i) = split(/\|/, $line);
18         $b =~ s/^\s*(\S+)\s*$/$1/o;
19         $i =~ s/^\s*(\S+)\s*$/$1/o;
20         $u_map{$b} = $i;
21 }
22 close F;
23
24 print "CREATE TABLE legacy_baduser_map ( barcode text, id int, type text);\n";
25 print "COPY legacy_baduser_map FROM STDIN;\n";
26
27 open F, $nonusers;
28 while (<F>) {
29         chomp;
30         my ($p,$l,$b) = split '\|';
31         next unless ($u_map{$b});
32         print "$b\t$u_map{$b}\tN\n";
33 }
34 close F;
35
36 open F, $recirc;
37 while (<F>) {
38         chomp;
39         my ($b) = split '\|';
40         next unless ($u_map{$b});
41         print "$b\t$u_map{$b}\tR\n";
42 }
43 close F;
44
45 print "\\.\n";
46