Merge branch 'master' into nigiri
authorWolfram Schneider <wosch@indexdata.dk>
Tue, 6 Apr 2010 15:25:54 +0000 (15:25 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Tue, 6 Apr 2010 15:25:54 +0000 (15:25 +0000)
bin/irspy-dump.pl [new file with mode: 0755]

diff --git a/bin/irspy-dump.pl b/bin/irspy-dump.pl
new file mode 100755 (executable)
index 0000000..a87177b
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+
+# Invoke as:
+#      $ mkdir records-2010-04-06
+#      $ cd records-2010-04-06
+#      $ irspy-dump.pl irspy.indexdata.com:8018/IR-Explain---1
+#      $ cd ..
+#      $ tar cfz records-2010-04-06.tar.gz records-2010-04-06
+
+use strict;
+use warnings;
+use ZOOM;
+
+if (@ARGV != 1) {
+    print STDERR "Usage: $0 target\n";
+    exit 1;
+}
+
+my $conn = new ZOOM::Connection($ARGV[0]);
+$conn->option(preferredRecordSyntax => "xml");
+$conn->option(elementSetName => "zebra::data");
+my $rs = $conn->search_pqf('@attr 1=_ALLRECORDS @attr 2=103 ""');
+my $n = $rs->size();
+$| = 1;
+print "$0: dumping $n records\n";
+foreach my $i (1..$n) {
+    print ".";
+    print " $i/$n (", int($i*100/$n), "%)\n" if $i % 50 == 0;
+    my $rec = $rs->record($i-1);
+    my $xml = $rec->render();
+    open F, ">$i.xml";
+    print F $xml;
+    close F;
+}
+print " $n/$n (100%)\n" if $n % 50 != 0;
+print "complete\n";