LP1754455 - Add option to marc_export to suppress output of 0 subfields user/dpearl/LP1754455_marc_export_zero
authorDan Pearl <dpearl@cwmars.org>
Fri, 9 Mar 2018 17:33:15 +0000 (12:33 -0500)
committerDan Pearl <dpearl@cwmars.org>
Fri, 9 Mar 2018 17:33:15 +0000 (12:33 -0500)
Signed-off-by: Dan Pearl <dpearl@cwmars.org>
Open-ILS/src/support-scripts/marc_export.in

index 4031874..e2acaca 100755 (executable)
@@ -86,6 +86,7 @@ sub new {
                'mfhd',
                'all',
                'replace_001',
+               'strip_0',
                'location=s',
                'money=s',
                'config=s',
@@ -126,6 +127,7 @@ Usage: $0 [options]
  --type or -t       Record type (BIBLIO, AUTHORITY) [BIBLIO]
  --all or -a        Export all records; ignores input list
  --replace_001      Replace the 001 field value with the record ID
+ --strip_0          Strip subfield 0 from all fields
  --store            Use the given storage backend to connect to the database.
                     Choices are (reporter, cstore, storage) [reporter]
  --since            Export records modified since a certain date and time.
@@ -524,6 +526,13 @@ sub next {
                         $marc->insert_fields_ordered($tcn);
                     }
                 }
+                if ($Marque::config->option_value('strip_0')) {
+                    my @my_fields = $marc->fields();
+                    foreach my $test_field (@my_fields){
+                       $test_field->MARC::Field::delete_subfield('0') 
+                          if !$test_field->is_control_field();
+                    }
+                }
                 if ($Marque::config->option_value('items')) {
                     my @acps = $self->acps_for_bre($r);
                     foreach my $acp (@acps) {
@@ -889,6 +898,13 @@ sub next {
                     $marc->insert_fields_ordered($tcn);
                 }
             }
+            if ($Marque::config->option_value('strip_0')) {
+                my @my_fields = $marc->fields();
+                foreach my $test_field (@my_fields){
+                   $test_field->MARC::Field::delete_subfield('0') 
+                      if !$test_field->is_control_field();
+                }
+            }
             if ($Marque::config->option_value('since')) {
                 my $leader = $marc->leader();
                 if ($U->is_true($r->deleted())) {