--- trunk/scripts/dump_fastmarc.pl 2010/09/23 13:51:58 45 +++ trunk/scripts/dump_fastmarc.pl 2013/08/22 10:48:18 46 @@ -35,12 +35,16 @@ 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 @@ 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}); }