[Koha-cvs] CVS: koha/misc bulkmarcimport.pl,1.5,1.6
Paul POULAIN
tipaul at users.sourceforge.net
Fri Dec 12 11:48:23 CET 2003
Update of /cvsroot/koha/koha/misc
In directory sc8-pr-cvs1:/tmp/cvs-serv24376/misc
Modified Files:
bulkmarcimport.pl
Log Message:
fixing bug in extended char import
Index: bulkmarcimport.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/bulkmarcimport.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** bulkmarcimport.pl 24 Nov 2003 17:15:55 -0000 1.5
--- bulkmarcimport.pl 12 Dec 2003 10:48:20 -0000 1.6
***************
*** 66,69 ****
--- 66,70 ----
print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
}
+
$char_encoding = 'MARC21' unless ($char_encoding);
print "CHAR : $char_encoding\n" if $verbose;
***************
*** 79,85 ****
$i++;
#now, parse the record, extract the item fields, and store them in somewhere else.
! $record = MARC::File::USMARC::decode(char_decode($record->as_usmarc(),$char_encoding));
! warn "$i ==>".$record->as_formatted() if $verbose eq 2;
! my @fields = $record->field($tagfield);
my @items;
my $nbitems=0;
--- 80,121 ----
$i++;
#now, parse the record, extract the item fields, and store them in somewhere else.
!
! # $record = MARC::File::USMARC::decode(char_decode($record->as_usmarc(),$char_encoding));
! ## create an empty record object to populate
! my $newRecord = MARC::Record->new();
!
! # go through each field in the existing record
! foreach my $oldField ( $record->fields() ) {
!
! # just reproduce tags < 010 in our new record
! if ( $oldField->tag() < 10 ) {
! $newRecord->append_fields( $oldField );
! next();
! }
!
! # store our new subfield data in this list
! my @newSubfields = ();
!
! # go through each subfield code/data pair
! foreach my $pair ( $oldField->subfields() ) {
! # upper case the data portion and store
! push( @newSubfields, $pair->[0], char_decode($pair->[1],$char_encoding) );
! }
!
! # add the new field to our new record
! my $newField = MARC::Field->new(
! $oldField->tag(),
! $oldField->indicator(1),
! $oldField->indicator(2),
! @newSubfields
! );
!
! $newRecord->append_fields( $newField );
!
! }
!
!
! warn "$i ==>".$newRecord->as_formatted() if $verbose eq 2;
! my @fields = $newRecord->field($tagfield);
my @items;
my $nbitems=0;
***************
*** 95,99 ****
# now, create biblio and items with NEWnewXX call.
unless ($test_parameter) {
! my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record);
warn "ADDED biblio NB $bibid in DB\n" if $verbose;
for (my $i=0;$i<=$#items;$i++) {
--- 131,135 ----
# now, create biblio and items with NEWnewXX call.
unless ($test_parameter) {
! my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$newRecord);
warn "ADDED biblio NB $bibid in DB\n" if $verbose;
for (my $i=0;$i<=$#items;$i++) {
More information about the Koha-cvs
mailing list