From: Dobrica Pavlinusic Date: Thu, 22 Aug 2013 10:48:18 +0000 (+0000) Subject: dump tsv file for TokyoCabinet import X-Git-Url: http://git.rot13.org/?p=MARC-Fast;a=commitdiff_plain;h=da0d66efdc1d4735f05935a6300a408e7f3ac503;hp=614bfc043eeaa5f8ae8de780d281d229021efc64 dump tsv file for TokyoCabinet import git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/MARC-Fast/trunk@46 49f9634a-d7ec-0310-8e6b-ec35c6cc8804 --- diff --git a/scripts/dump_fastmarc.pl b/scripts/dump_fastmarc.pl index f9e96f2..dd4897c 100755 --- a/scripts/dump_fastmarc.pl +++ b/scripts/dump_fastmarc.pl @@ -35,12 +35,16 @@ dump result of C on record turn debugging output on +=item -t + +dump tsv file for TokyoCabinet import + =back =cut my %opt; -getopts('do:l:h', \%opt); +getopts('do:l:ht', \%opt); my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-h] [-d] file.marc\n"; @@ -65,9 +69,16 @@ if (my $mfn = $opt{n}) { for my $mfn ($min .. $max) { my $rec = $marc->fetch($mfn) || next; - print "rec is ",dump($rec) if ($opt{d}); - print "REC $mfn\n"; - print $marc->last_leader,"\n"; - print $marc->to_ascii($mfn),"\n"; - print "hash is ",dump($marc->to_hash($mfn, include_subfields => 1)) if ($opt{h}); + warn "rec is ",dump($rec) if ($opt{d}); + if ( $opt{t} ) { + print "rec\t$mfn\tleader\t", $marc->last_leader, "\t"; + my $ascii = $marc->to_ascii($mfn); + $ascii =~ s{\n}{\t}gs; + print "$ascii\n"; + } else { + print "REC $mfn\n"; + print $marc->last_leader,"\n"; + print $marc->to_ascii($mfn),"\n"; + } + warn "hash is ",dump($marc->to_hash($mfn, include_subfields => 1)) if ($opt{h}); }