From b88682f1bbea70f2b25cbaf6a30f60776b2ea4f8 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 8 Feb 2008 16:55:41 -0600 Subject: [PATCH] bug 1372: count MARC records correctly Signed-off-by: Joshua Ferraro --- C4/ImportBatch.pm | 3 +++ misc/stage_biblios_file.pl | 4 ++++ tools/stage-marc-import.pl | 3 +++ 3 files changed, 10 insertions(+) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 0c93ccd0f1..283de042e0 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -266,6 +266,9 @@ sub BatchStageMarcRecords { # FIXME - for now, we're dealing only with bibs my $rec_num = 0; foreach my $marc_blob (split(/\x1D/, $marc_records)) { + $marc_blob =~ s/^\s+//g; + $marc_blob =~ s/\s+$//g; + next unless $marc_blob; $rec_num++; if ($progress_interval and (0 == ($rec_num % $progress_interval))) { &$progress_callback($rec_num); diff --git a/misc/stage_biblios_file.pl b/misc/stage_biblios_file.pl index 671bc86bd4..cf140c26f8 100755 --- a/misc/stage_biblios_file.pl +++ b/misc/stage_biblios_file.pl @@ -54,6 +54,10 @@ sub process_batch { $/ = "\035"; my $num_input_records = 0; while () { + s/^\s+//; + s/\s+$//; + next unless $_; # skip if record has only whitespace, as might occur + # if file includes newlines between each MARC record $marc_records .= $_; # FIXME - this sort of string concatenation # is probably rather inefficient $num_input_records++; diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl index e75019a8f0..3075c525ce 100755 --- a/tools/stage-marc-import.pl +++ b/tools/stage-marc-import.pl @@ -75,7 +75,10 @@ if ($completedJobID) { my $uploaded_file = C4::UploadedFile->fetch($sessionID, $fileID); my $fh = $uploaded_file->fh(); my $marcrecord=''; + $/ = "\035"; while (<$fh>) { + s/^\s+//; + s/\s+$//; $marcrecord.=$_; } -- 2.39.2