[Koha-patches] [PATCH] Bug 5067 Add a parameter do disable ISBN cleaning
Frédéric Demians
f.demians at tamil.fr
Thu Jul 29 11:31:21 CEST 2010
By default, bulkmarcimport.pl was cleaning hyphens from ISBN in entering
biblio records. A new parameter -cleanisbn allows to disable ISBN
cleaing. By default, bulkmarcimport.pl continues to remove ISBN hyphens.
You have to add -nocleanisbn to disable it explicitely.
---
misc/migration_tools/bulkmarcimport.pl | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl
index da0ebf7..8c14928 100755
--- a/misc/migration_tools/bulkmarcimport.pl
+++ b/misc/migration_tools/bulkmarcimport.pl
@@ -34,6 +34,7 @@ binmode(STDOUT, ":utf8");
my ( $input_marc_file, $number, $offset) = ('',0,0);
my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile);
my ($sourcetag,$sourcesubfield,$idmapfl);
+my $cleanisbn = 1;
$|=1;
@@ -59,6 +60,7 @@ GetOptions(
'x:s' => \$sourcetag,
'y:s' => \$sourcesubfield,
'idmap:s' => \$idmapfl,
+ 'cleanisbn!' => \$cleanisbn,
);
$biblios=!$authorities||$biblios;
@@ -196,19 +198,13 @@ RECORD: while ( ) {
}
my $isbn;
# remove trailing - in isbn (only for biblios, of course)
- if ($biblios) {
- if ($marcFlavour eq 'UNIMARC') {
- if (my $f010 = $record->field('010')) {
- $isbn = $f010->subfield('a');
- $isbn =~ s/-//g;
- $f010->update('a' => $isbn);
- }
- } else {
- if (my $f020 = $record->field('020')) {
- $isbn = $f020->subfield('a');
- $isbn =~ s/-//g;
- $f020->update('a' => $isbn);
- }
+ if ($biblios && $cleanisbn) {
+ my $tag = $marcFlavour eq 'UNIMARC' ? '010' : '020';
+ my $field = $record->field($tag);
+ my $isbn = $field && $field->subfield('a');
+ if ( $isbn ) {
+ $isbn =~ s/-//g;
+ $field->update('a' => $isbn);
}
}
my $id;
@@ -517,6 +513,11 @@ If set, a search will be done on isbn, and, if the same isbn is found, the
biblio is not added. It's another method to deduplicate. B<-match> & B<-isbn>
can be both set.
+=item B<-cleanisbn>
+
+Clean ISBN fields from entering biblio records, ie removes hyphens. By default,
+ISBN are cleaned. --nocleanisbn will keep ISBN unchanged.
+
=item B<-x>=I<TAG>
Source bib I<TAG> for reporting the source bib number
--
1.7.1
More information about the Koha-patches
mailing list