[open-ils-commits] r10300 - trunk/Open-ILS/src/extras/import
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 7 11:08:32 EDT 2008
Author: dbs
Date: 2008-08-07 11:08:26 -0400 (Thu, 07 Aug 2008)
New Revision: 10300
Modified:
trunk/Open-ILS/src/extras/import/marc2bre.pl
Log:
Add a --required_field option to enable skipping records that don't contain a required field
Modified: trunk/Open-ILS/src/extras/import/marc2bre.pl
===================================================================
--- trunk/Open-ILS/src/extras/import/marc2bre.pl 2008-08-07 14:30:43 UTC (rev 10299)
+++ trunk/Open-ILS/src/extras/import/marc2bre.pl 2008-08-07 15:08:26 UTC (rev 10300)
@@ -22,7 +22,7 @@
#MARC::Charset->ignore_errors(1);
-my ($id_field, $id_subfield, $recid, $user, $config, $idlfile, $marctype, $keyfile, $dontuse_file, $enc, $force_enc, @files, @trash_fields, $quiet) =
+my ($id_field, $id_subfield, $recid, $user, $config, $idlfile, $marctype, $keyfile, $dontuse_file, $enc, $force_enc, @files, @trash_fields, @req_fields, $quiet) =
('', 'a', 0, 1, '/openils/conf/opensrf_core.xml', '/openils/conf/fm_IDL.xml', 'USMARC');
my ($db_driver,$db_host,$db_name,$db_user,$db_pw) =
@@ -39,6 +39,7 @@
'keyfile=s' => \$keyfile,
'config=s' => \$config,
'file=s' => \@files,
+ 'required_field=s' => \@req_fields,
'trash=s' => \@trash_fields,
'xml_idl=s' => \$idlfile,
'dontuse=s' => \$dontuse_file,
@@ -130,8 +131,13 @@
my $starttime = time;
my $rec;
my $count = 0;
-while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) {
+PROCESS: while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) {
next if ($rec == -1);
+
+ # Skip records that don't contain a required field (like '245', for example)
+ foreach my $req_field(@req_fields) {
+ next PROCESS if !$rec->field("$req_field");
+ }
my $id;
$recid++;
More information about the open-ils-commits
mailing list