Removing duplicate fields with MARC::record

2007-07-30 Thread Michael Bowden
Hi Folks:
 
It is me again.  I have another question...
 
I am helping someone clean up her database.  Somehow, the 856 field in her MARC 
records has duplicated itself several times.  She has some records with 15+ 
duplicate 856 fields.  So I am trying, unsuccessfully, to modify one of my 
scripts to delete the duplicate fields.  The problem I am having is that out of 
the 15+ 856 fields, 3 of the 856 fields are unique to the record and need to 
stay.  Here is my code so far:
 
## create a MARC::File::USMARC object
 
use MARC::Batch;
 
my $infile = shift;
my $otfile = shift;
my $batch = MARC::Batc
 
Michael L. Bowden
Coordinator of Automation and Access Services
Associate Professor, Information Science
Harrisburg Area Community College
One HACC Drive
Harrisburg, PA 17110-2999

E: [EMAIL PROTECTED]
T: 717.780.1936
F: 717.780.2462h-new('USMARC',$infile);
$batch-strict_off();
 
open (DBOUT,  $otfile);
## if $file isn't defined we had trouble with the file
## so exit
 
if (not($infile)) {
print $MARC::File::ERROR,\n;
exit(0);
}
 
while (my $record = $batch-next()) {
   my @m856 = $record-field('856');
   @m856 = sort {$a cmp $b} @m856;
   my %seen = ();
   my @new856 = ();
   
   foreach ( $record-fields() ) {
  if (@m856) {
 foreach $f (@m856) {
 next if ($seen{ $f }++);
   push @new856, $f;
 $record-delete_field($f);
 }
 }
   }
   $record-insert_fields_ordered( @new856 );
   print DBOUT $record-as_usmarc();
}
 
When I run this script, It put ALL the 856 fields back in the record and they 
are not sort. What am I doing wrong?
 
TIA!
 
Michael

Harrisburg Area Community College



Removing duplicate fields with MARC::record

2007-07-30 Thread Michael Bowden
Hi Folks:
 
Hmmm...  I am not sure how my address got in the middle of the code in that 
last message.  Here is a corrected version!  
 
Michael
 
 
 
It is me again.  I have another question...
 
I am helping someone clean up her database.  Somehow, the 856 field in her MARC 
records has duplicated itself several times.  She has some records with 15+ 
duplicate 856 fields.  So I am trying, unsuccessfully, to modify one of my 
scripts to delete the duplicate fields.  The problem I am having is that out of 
the 15+ 856 fields, 3 of the 856 fields are unique to the record and need to 
stay.  Here is my code so far:
 
## create a MARC::File::USMARC object
 
use MARC::Batch;
 
my $infile = shift;
my $otfile = shift;
my $batch = MARC::Batc

## if $file isn't defined we had trouble with the file
## so exit
 
if (not($infile)) {
print $MARC::File::ERROR,\n;
exit(0);
}
 
while (my $record = $batch-next()) {
   my @m856 = $record-field('856');
   @m856 = sort {$a cmp $b} @m856;
   my %seen = ();
   my @new856 = ();
   
   foreach ( $record-fields() ) {
  if (@m856) {
 foreach $f (@m856) {
 next if ($seen{ $f }++);
   push @new856, $f;
 $record-delete_field($f);
 }
 }
   }
   $record-insert_fields_ordered( @new856 );
   print DBOUT $record-as_usmarc();
}
 
When I run this script, It put ALL the 856 fields back in the record and they 
are not sort. What am I doing wrong?
 
TIA!
 
Michael
 
 

Harrisburg Area Community College



Using MARC::Record to delete fields

2007-07-16 Thread Michael Bowden
Hi:
 
I have used MARC::Record for several years now.  I finally have hit a snag in 
processing MARC records.  Our MARC records have several 035 fields.  I want to 
delete all of the 035s except for the 1st one.  I have tried several things to 
accomplish this task without any luck.  I have tried to delete all the 035s and 
then add back the one 035 that I want to keep.  I have discovered that 
$record-delete_field(@m035) deletes all the 035s EXCEPT for the last one.  
Here is my code:
 
while (my $record = $batch-next()) {
   my @m035 = $record-field('035');
   
   foreach ( $record-fields() ) {
  if (@m035) {
 $record-delete_field(@m035);
 }
  print $record-as_formatted(),\n\n;
   }
 
Am I doing something wrong in trying to delete all the 035s?
 
All suggestions are greatly appreciated!
 
Michael
 
Michael L. Bowden
Harrisburg Area Community College
[EMAIL PROTECTED]
 

 

Harrisburg Area Community College



Adding non standard MARC subfields with MARC::Record

2004-04-02 Thread Michael Bowden
 
Sirsi uses some non standard subfields to create links between records.
 Typically these subfields are '?' and '='.  How can I add these non
standard subfields to records that I am creating/editing with
MARC::Record?
 
Michael
 
Michael L. Bowden
Coordinator of Automation and Access Services
Assistant Professor, Information Science
Harrisburg Area Community College
One HACC Drive
Harrisburg, PA 17110-2999
 
E: [EMAIL PROTECTED]
T: 717.780.1936
F: 717.780.2462