Add 006 and 007 tags to records?

2011-05-12 Thread Nolte, Jennifer
Hello-

I am working on a shell script that will process the MARC records that 
represent items from our e-serials management database, and the thing I am 
stuck on is adding brand new 006 and 007 fixed field tags to each record. I am 
using the marcedit.pl fieldaddtobeg function, but it corrupts the records and 
makes them unparseable.

Is there a quick and easy way to do this within a script? (I know Perl works 
best with MARC but I am open to any suggestions).

Thank you!!

~Jenn

Jenn Nolte
Applications Manager / Database Administrator
Production Systems Team
Information Technology Office
Yale University Library
130 Wall St.
New Haven CT 06520
203 432 4878



RE: Add 006 and 007 tags to records?

2011-05-12 Thread Bryan Baldus
On Thursday, May 12, 2011 10:58 AM, Jenn Nolte wrote:
>I am working on a shell script that will process the MARC records that 
>represent items from our e-serials management database, and the thing I am 
>stuck on is adding brand new 006 and 007 fixed field tags to each record. I am 
>using the marcedit.pl fieldaddtobeg function, but it corrupts the records and 
>makes them unparseable.
>Is there a quick and easy way to do this within a script? (I know Perl works 
>best with MARC but I am open to any suggestions).

I'm not familiar with marcedit.pl. I'd use MARC::Batch and its related modules, 
similar to the mock-up listed below (which assumes the 008 to be present to 
insert the new field(s) in the proper order; I've thrown the code together 
haphazardly, so it may contain errors). Of course with 006 and 007, you also 
run into length issues--006 is always 18 bytes; 007's length depends on the 
category of material. If the fields don't have the correct length, some systems 
may reject the records.

##

use MARC::Batch;

#$inputfile = "path_to_your_file_however_you_get_it";

my $batch = MARC::Batch->new('USMARC', "$inputfile");

#$exportfile = "path_to_your_file_however_you_get_it";

open(OUT, ">$exportfile") or die "Can not open $exportfile, $!";

RECORD: while (my $record = $batch->next()) {

#   $field006 = ''; #string of valid 006 characters (change 006 to 007 for 
007)
my $new006 = MARC::Field->new( '006', $field006);
$record->insert_fields_before($record->field('008'), ($new006));

print OUT $record->as_usmarc();

}# while records

#

I hope this helps,

Bryan Baldus
Cataloger
Quality Books Inc.
The Best of America's Independent Presses
1-800-323-4241x402
bryan.bal...@quality-books.com
eij...@cpan.org
http://home.comcast.net/~eijabb/



Re: Add 006 and 007 tags to records?

2011-05-12 Thread Roy Zimmer
Jenn, that's a misapplication of the fieldaddtobeg function. Here's the 
definition for that function:


fieldaddtobeg | field | data
  field   3 digits specify the field
  datanew field data added to the beginning of the field
  (only for fields without indicators (001-009)

It adds data to the beginning of those sub-010 fields. It does not add a 
new field.


To add a field, use the ADD stanza; from the documentation:

[ADD]
field | L1 | L2 | # | subfield | data

  field
3 digits specify which field to add
  L1
the first indicator character; space if empty
  L2
the second indicator character; space if empty
  #
the number of subfield+data pairings following
  subfield
1 character denoting the subfield
  data
the subfield data

In each case, the field, with specified indicators, if any, subfield, 
and data

is added as a complete field, whether or not such a field already exists.

If you're adding a fixed field, leave L1, L2, "#", and subfield blank, 
empty,

i.e., not even a space; to wit:  009|this is 009 stuff

I hope this helps.

Roy


On 5/12/2011 12:48 PM, Bryan Baldus wrote:

On Thursday, May 12, 2011 10:58 AM, Jenn Nolte wrote:

I am working on a shell script that will process the MARC records that 
represent items from our e-serials management database, and the thing I am 
stuck on is adding brand new 006 and 007 fixed field tags to each record. I am 
using the marcedit.pl fieldaddtobeg function, but it corrupts the records and 
makes them unparseable.
Is there a quick and easy way to do this within a script? (I know Perl works 
best with MARC but I am open to any suggestions).

I'm not familiar with marcedit.pl. I'd use MARC::Batch and its related modules, 
similar to the mock-up listed below (which assumes the 008 to be present to 
insert the new field(s) in the proper order; I've thrown the code together 
haphazardly, so it may contain errors). Of course with 006 and 007, you also 
run into length issues--006 is always 18 bytes; 007's length depends on the 
category of material. If the fields don't have the correct length, some systems 
may reject the records.

##

use MARC::Batch;

#$inputfile = "path_to_your_file_however_you_get_it";

my $batch = MARC::Batch->new('USMARC', "$inputfile");

#$exportfile = "path_to_your_file_however_you_get_it";

open(OUT, ">$exportfile") or die "Can not open $exportfile, $!";

RECORD: while (my $record = $batch->next()) {

#   $field006 = ''; #string of valid 006 characters (change 006 to 007 for 
007)
 my $new006 = MARC::Field->new( '006', $field006);
 $record->insert_fields_before($record->field('008'), ($new006));

print OUT $record->as_usmarc();

}# while records

#

I hope this helps,

Bryan Baldus
Cataloger
Quality Books Inc.
The Best of America's Independent Presses
1-800-323-4241x402
bryan.bal...@quality-books.com
eij...@cpan.org
http://home.comcast.net/~eijabb/



Re: Add 006 and 007 tags to records?

2011-05-12 Thread Paul Hoffman
On Thu, May 12, 2011 at 11:58:07AM -0400, Nolte, Jennifer wrote:
> I am working on a shell script that will process the MARC records that
> represent items from our e-serials management database, and the thing
> I am stuck on is adding brand new 006 and 007 fixed field tags to each
> record. I am using the marcedit.pl fieldaddtobeg function, but it
> corrupts the records and makes them unparseable.
> 
> Is there a quick and easy way to do this within a script? (I know Perl
> works best with MARC but I am open to any suggestions).

I've written a bunch of MARC manipulation scripts meant to be used at
the command line or in shell scripts; appending 006 and 007 fields would
go something like this:

$ f006='ebd...'
$ f007='aj cafua'
$ marcappend 006 [ $f006 ] 007 [ $f007 ] < $file | marcgroom -0

It should be pretty obvious what marcappend does; marcgroom reorders
fields within a group (-0 to reorder 0xx fields, -1 to reorder 1xx
fields, etc.).

Holler if you're interested.  These two particular scripts only depend
on Getopt::Long -- I wrote them at a time when I preferred to include
MARC record parsing code in each script rather than using MARC::Record
or some such.

Paul.

-- 
(Insert cute and/or geeky .sig here)


RE: Add 006 and 007 tags to records?

2011-05-19 Thread Nolte, Jennifer
Roy-

THANK YOU! I was going crazy.

~Jenn

From: roy.zim...@wmich.edu [mailto:roy.zim...@wmich.edu]
Sent: Thursday, May 12, 2011 2:33 PM
To: perl4lib@perl.org; Nolte, Jennifer
Subject: Re: Add 006 and 007 tags to records?

Jenn, that's a misapplication of the fieldaddtobeg function. Here's the 
definition for that function:

fieldaddtobeg | field | data
  field   3 digits specify the field
  datanew field data added to the beginning of the field
  (only for fields without indicators (001-009)

It adds data to the beginning of those sub-010 fields. It does not add a new 
field.

To add a field, use the ADD stanza; from the documentation:

[ADD]
field | L1 | L2 | # | subfield | data

  field
3 digits specify which field to add
  L1
the first indicator character; space if empty
  L2
the second indicator character; space if empty
  #
the number of subfield+data pairings following
  subfield
1 character denoting the subfield
  data
the subfield data

In each case, the field, with specified indicators, if any, subfield, and data
is added as a complete field, whether or not such a field already exists.

If you're adding a fixed field, leave L1, L2, "#", and subfield blank, empty,
i.e., not even a space; to wit:  009|this is 009 stuff

I hope this helps.

Roy


On 5/12/2011 12:48 PM, Bryan Baldus wrote:

On Thursday, May 12, 2011 10:58 AM, Jenn Nolte wrote:

I am working on a shell script that will process the MARC records that 
represent items from our e-serials management database, and the thing I am 
stuck on is adding brand new 006 and 007 fixed field tags to each record. I am 
using the marcedit.pl fieldaddtobeg function, but it corrupts the records and 
makes them unparseable.

Is there a quick and easy way to do this within a script? (I know Perl works 
best with MARC but I am open to any suggestions).



I'm not familiar with marcedit.pl. I'd use MARC::Batch and its related modules, 
similar to the mock-up listed below (which assumes the 008 to be present to 
insert the new field(s) in the proper order; I've thrown the code together 
haphazardly, so it may contain errors). Of course with 006 and 007, you also 
run into length issues--006 is always 18 bytes; 007's length depends on the 
category of material. If the fields don't have the correct length, some systems 
may reject the records.



##



use MARC::Batch;



#$inputfile = "path_to_your_file_however_you_get_it";



my $batch = MARC::Batch->new('USMARC', "$inputfile");



#$exportfile = "path_to_your_file_however_you_get_it";



open(OUT, ">$exportfile") or die "Can not open $exportfile, $!";



RECORD: while (my $record = $batch->next()) {



#   $field006 = ''; #string of valid 006 characters (change 006 to 007 for 
007)

my $new006 = MARC::Field->new( '006', $field006);

$record->insert_fields_before($record->field('008'), ($new006));



print OUT $record->as_usmarc();



}# while records



#



I hope this helps,



Bryan Baldus

Cataloger

Quality Books Inc.

The Best of America's Independent Presses

1-800-323-4241x402

bryan.bal...@quality-books.com<mailto:bryan.bal...@quality-books.com>

eij...@cpan.org<mailto:eij...@cpan.org>

http://home.comcast.net/~eijabb/