projects
/
koha-eprints
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7b2117f
)
use column names from first line of tsv
author
dpavlin
<dpavlin@rot13.org>
Mon, 25 May 2015 12:25:49 +0000
(14:25 +0200)
committer
dpavlin
<dpavlin@rot13.org>
Mon, 25 May 2015 12:25:49 +0000
(14:25 +0200)
tsv2eprints.pl
patch
|
blob
|
history
diff --git
a/tsv2eprints.pl
b/tsv2eprints.pl
index
7535069
..
a86a04f
100755
(executable)
--- a/
tsv2eprints.pl
+++ b/
tsv2eprints.pl
@@
-254,14
+254,26
@@
open(my $marc_fh, '<', "$koha_path.marc");
open(my $import_fh, '>', "$koha_path.import.marc");
my $last_offset = 0;
open(my $import_fh, '>', "$koha_path.import.marc");
my $last_offset = 0;
+my @cols;
while(<$tsv_fh>) {
my $line = $_;
$line =~ s/[\n\r]+$//;
while(<$tsv_fh>) {
my $line = $_;
$line =~ s/[\n\r]+$//;
- my ($offset, $biblionumber, $title) = split(/\t/,$_,3);
+ if ( ! @cols && $line =~ m/#(.+)/ ) {
+ @cols = split(/\t/, $1);
+ next;
+ }
+
+ my @v = split(/\t/, $_, $#cols + 1);
+ my %row;
+ @row{@cols} = @v;
+warn "## row = ",dump( \%row );
+
+ my $offset = $row{offset} // die "no offset";
+ my $biblionumber = $row{biblionumber} || die "no biblionumber";
- warn "#
$offset $biblionumber $title
\n";
+ warn "#
", join(' ', map { $row{$_} } qw(offset biblionumber title)), "
\n";
exit if $ENV{LAST} && $eprintid >= $ENV{LAST};
exit if $ENV{LAST} && $eprintid >= $ENV{LAST};
@@
-273,7
+285,7
@@
while(<$tsv_fh>) {
seek $marc_fh, $last_offset, 0;
read $marc_fh, my $marc, $offset - $last_offset;
print $import_fh $marc;
seek $marc_fh, $last_offset, 0;
read $marc_fh, my $marc, $offset - $last_offset;
print $import_fh $marc;
- warn "# marc $biblionumber
$title
\n";
+ warn "# marc $biblionumber\n";
} else {
$stat->{missing}++;
} else {
$stat->{missing}++;