Script by Galen, used in dedupe/merge processing.
authorBen Ostrowsky <ben@esilibrary.com>
Tue, 10 May 2011 18:46:59 +0000 (18:46 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 16 Jul 2012 15:30:59 +0000 (11:30 -0400)
cleanup_merge_map.pl [new file with mode: 0644]

diff --git a/cleanup_merge_map.pl b/cleanup_merge_map.pl
new file mode 100644 (file)
index 0000000..b00c9e3
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+cleanup_merge_map.pl
+
+=head2 SUMMARY
+
+Little helper script used when consoldating
+multiple merge maps.
+
+=cut
+
+my %bad_subs = ();
+my %map = ();
+while (<>) {
+    chomp;
+    my ($lead, $sub) = split /\t/, $_, -1;
+    next if exists $bad_subs{$sub};
+    if (exists $map{$sub}) {
+        $bad_subs{$sub}++;
+        delete $map{$sub};
+        next;
+    }
+    $map{$sub} = $lead;
+}
+foreach my $sub (sort keys %map) {
+    print "$map{$sub}\t$sub\n";
+}
+
+