From: dpavlin Date: Tue, 26 May 2015 11:54:04 +0000 (+0200) Subject: cleanup code a bit X-Git-Url: http://git.rot13.org/?p=koha-eprints;a=commitdiff_plain;h=0a826de145ac6aa610ec3375ededfbb81721ab23 cleanup code a bit --- diff --git a/tsv2eprints.pl b/tsv2eprints.pl index a275fa4..7c9ea89 100755 --- a/tsv2eprints.pl +++ b/tsv2eprints.pl @@ -64,8 +64,6 @@ $repo->terminate(); =cut -our $eprintid = 1; - my $files; my $mkp_path = "/mnt/share/MKP/ELEKTRONIČKI DOKUMENTI/EL.DOKUMENTI PO BIBLIOBROJU/"; @@ -103,6 +101,7 @@ my $last_offset = 0; my @cols; while(<$tsv_fh>) { + chomp; my $line = $_; $line =~ s/[\n\r]+$//; @@ -111,7 +110,7 @@ while(<$tsv_fh>) { next; } - my @v = split(/\t/, $_, $#cols + 1); + my @v = split(/\t/, $line, $#cols + 1); my %row; @row{@cols} = @v; #warn "## row = ",dump( \%row ); @@ -119,9 +118,7 @@ while(<$tsv_fh>) { my $offset = $row{offset} // die "no offset"; my $biblionumber = $row{biblionumber} || die "no biblionumber"; - warn "# ", join(' ', map { $row{$_} } qw(offset biblionumber title)), "\n"; - - exit if $ENV{LAST} && $eprintid >= $ENV{LAST}; +# warn "# ", join(' ', map { $row{$_} } qw(biblionumber title)), "\n"; if ( delete $files->{$biblionumber} ) { $stat->{file}++; @@ -136,7 +133,9 @@ while(<$tsv_fh>) { seek $marc_fh, $last_offset, 0; read $marc_fh, my $marc, $offset - $last_offset; print $import_fh $marc; - warn "# marc $biblionumber\n"; + warn "# NEW ", join(' ', map { $row{$_} } qw(biblionumber title)), "\n"; +# warn "# NEW $biblionumber\n"; + } } else { @@ -160,6 +159,7 @@ foreach my $biblionumber ( keys %$files ) { if ( my $marc = get("https://koha.ffzg.hr/cgi-bin/koha/opac-export.pl?op=export&bib=$biblionumber&format=utf8") ) { print $import_fh $marc; warn "## marc $biblionumber from koha!"; + $stat->{koha}++; } else { warn "ERROR: can't fetch $biblionumber from koha"; }