marc_export.pl is a small multipurpose script that can be used to export MARC records from Voyager according to different criteria (bib id list, bib id range, list of identifiers etc.). It can do a bit of on-the-fly record manipulation and output the records in ISO2709 (the classic MARC exchange format) or MARCXML.
- Author: Ere Maijala
- Additional author(s):
- Institution: None
- Year: 2010
- License: MPL 1.1 / GPL 2.0
- Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.
- Link to terms: MPL 1.1, GPL 2.0
- Skill required for using this code: basic
Voyager, read-only access to Oracle
- First public release
The script doesn't need much installation. Just copy to server, make it executable (chmod +x marc_export.pl) and run it without parameters for a quick help. If it doesn't work, check that it didn't accidentally get Windows line-endings and that the Oracle path in ORACLE_HOME is correct.
marc_export.pl will examine all the bib records in the database (unless first_id and/or last_id are specified). It's not fast, but this keeps it relatively simple.
The only mandatory parameters are:
|output_file||Name of the output file|
|user||Oracle read-only user (e.g. ro_xxxdb)|
|password||Oracle read-only user's password|
Without any further parameters the script will export all records in ISO2709 format. The following parameters can be used to control the output:
|format||Output format, one of: iso2709 (default, the MARC exchange format), marcxml or bib_id (only bib record id's)|
|marcxml_namespace||Namespace declaration to use when exporting records in MARCXML format|
To export records according to a list of bib id's, create a file of id's (one per line), and use the enter the file name in the id_file parameter.
To export records according to a bib id range, use either or both first_id and last_id parameters.
To export records according to field contents, e.g. when you have a list of ISBN's in a file, you can use the following parameters:
|field||The field to be examined, e.g. 022|
|subfield||The subfield to be examined, e.g. a|
|field_file||File containing the values that will be searched for in the records|
|case_sensitive||A boolean flag making the field contents comparison case-sensitive (default is case-insensitive)|
|ignore_punctuation||A boolean flag making the field contents comparison ignore punctuation characters|
|report||A file name where the export writes a report of field contents that have been found in multiple records or no records at all|
|field_comparison||The method used when comparing the field contents with the values in the field_file. Possible choices are: exact (match the full subfield), beginning (match the beginning of the subfield), substring (match anywhere in the subfield), end (match the end of the subfield) or regexp (lines in field_file are treated as regular expressions)|
It is also possible to add a field to the outputted records. In this case the field_file must contain the string to search for, a pipe character and the string to be added to the record. Parameters add_field
and add_subfield specify the field code and subfield to be added. This can be used to do generic additions to records, e.g.
or record-specific identifiers, e.g.
Note that the longer the file containing the field contents, the slower the export as each record will be checked for a match in any of the values.
Export records in MARCXML format according to a list ISBN's (match the beginning, as there might be something like (pbk) in the end) and write a report into report.txt:
Export record 10000 - 12000:
Export records according to field 015a and add field 500 to the outputted records:
More options as needed.
The export is slow. To keep it simple, it doesn't use any indexes or such.