yaz-marcdump — MARC record dump utility
yaz-marcdump [-i ] [format-o ] [format-f ] [from-t ] [to-l ] [spec-c ] [cfile-s ] [prefix-C ] [size-O ] [offset-L ] [limit-n] [-p] [-r] [-v] [-V] [file...]
yaz-marcdump reads MARC records from one or more files. It parses each record and supports output in line-format, ISO2709, MARCXML, MARC-in-JSON, MarcXchange as well as Hex output.
This utility parses records ISO2709(raw MARC), line format, MARC-in-JSON format as well as XML if that is structured as MARCXML/MarcXchange.
MARC-in-JSON encoding/decoding is supported in YAZ 5.0.5 and later.
As of YAZ 2.1.18, OAI-MARC is no longer supported. OAI-MARC is deprecated. Use MARCXML instead.
By default, each record is written to standard output in a line
format with newline for each field, $x for each sub-field x.
The output format may be changed with option -o,
yaz-marcdump can also be requested to perform character set conversion of each record.
format
Specifies input format. Must be one of
marcxml, marc (ISO2709),
marcxchange (ISO25577),
line (line mode MARC),
turbomarc (Turbo MARC),
json (MARC-in-JSON),
or jsonlines (one MARC-in-JSON record per line).
format
Specifies output format. Must be one of
marcxml, marc (ISO2709),
marcxchange (ISO25577),
line (line mode MARC),
turbomarc (Turbo MARC),
json (MARC-in-JSON),
or jsonlines (one compact MARC-in-JSON record per line).
from
Specify the character set
of the input MARC record.
Should be used in conjunction with option -t.
Refer to the yaz-iconv man page for supported character sets.
to
Specify the character set
of the output.
Should be used in conjunction with option -f.
Refer to the yaz-iconv man page for supported character sets.
leaderspec
Specify a simple modification string for MARC leader. The
leaderspec is a list of pos=value
pairs, where pos is an integer offset (0 - 23) for leader. Value
is either a quoted string or an integer (character value in decimal).
Pairs are comma separated. For example, to set leader at offset 9
to a, use 9='a'.
prefix
Writes a chunk of records to a separate file with prefix given,
i.e. splits a record batch into files with only at most
"chunk" ISO2709 records per file. By default chunk is 1 (one record
per file). See option -C.
chunksize
Specifies chunk size; to be used conjunction with option
-s.
offsetInteger offset for at what position records whould be written. 0=first record, 1=second, .. With -L option, this allows a specific range of records to be processed.
limitInteger limit for how many records should at most be written. With -O option, this allows a specific range of records to be processed.
Makes yaz-marcdump print record number and input file offset of each record read.
MARC output is omitted so that MARC input is only checked.
Writes to stderr a summary about number of records read by yaz-marcdump.
Writes more information about the parsing process. Useful if you have ill-formatted ISO2709 records as input.
Prints YAZ version.
The json format follows Ross Singer's
MARC-in-JSON proposal.
Each record is a JSON object with a leader string
containing the 24-character MARC leader and a fields
array containing the fields in record order.
Each field is an object with one member whose name is the field tag.
Tags are strings, so leading zeroes are retained. For a control field,
the value is a string containing the field data. For a data field,
the value is an object containing indicator members named
ind1, ind2, etc., each holding a
one-character string, and a subfields array.
YAZ supports the indicator count specified at leader offset 10
(counting from zero), as defined by ISO2709. MARC21 uses two indicators;
a record with three indicators uses ind1,
ind2, and ind3, with
3 at leader offset 10. A blank indicator is
represented by a space (" ").
Each subfield is an object with one member: the subfield code is the name and the subfield data is the string value. Field and subfield arrays preserve order and allow repeated tags and codes as separate objects. JSON object member order has no significance. For example:
{
"leader": "00000nam a2200000 a 4500",
"fields": [
{"001": "12345"},
{"245": {
"ind1": "0",
"ind2": "0",
"subfields": [
{"a": "An example title :"},
{"b": "a subtitle."}
]
}},
{"650": {
"ind1": " ",
"ind2": "0",
"subfields": [
{"a": "Libraries"},
{"x": "Automation"},
{"x": "Standards."}
]
}},
{"650": {
"ind1": " ",
"ind2": "0",
"subfields": [{"a": "Cataloging."}]
}}
]
}
With -i json, yaz-marcdump
expects one record object per input file. With -o json,
it writes successive record objects without an enclosing array.
Use -f and -t UTF-8 to convert
records from another character encoding for JSON output.
With -o jsonlines, each record is written as one
compact JSON object followed by a newline, following the
JSON Lines format.
The record structure is the same as for -o json;
whitespace within strings is preserved and embedded newlines are escaped.
Multiple records and input files produce successive lines without an
enclosing array. Empty input produces no output. For example:
yaz-marcdump -f MARC-8 -t UTF-8 -o jsonlines records.marc > records.jsonl
JSON Lines uses UTF-8; supply -f and
-t UTF-8 when conversion is required.
With -i jsonlines, input is read one record line at
a time. Both LF and CRLF line endings are accepted, and the final
record may omit its newline. Each line must contain one MARC-in-JSON
object; blank lines are errors. Input lines are limited to 1 MiB
(1,048,576 bytes, excluding the LF delimiter). Oversized or malformed
lines are reported with the filename and line number and skipped;
subsequent lines are still processed and the command exits with a
nonzero status. The -O and -L
options select a range of input record lines. For example:
yaz-marcdump -i jsonlines -o marcxml records.jsonl > records.xml
The input buffer and parsed record are reused or released between
lines, so memory does not grow with the total number of records.
The -i json format continues to expect one record
object per file.
The following command converts MARC21/USMARC in MARC-8 encoding to MARC21/USMARC in UTF-8 encoding. Leader offset 9 is set to 'a'. Both input and output records are ISO2709 encoded.
yaz-marcdump -f MARC-8 -t UTF-8 -o marc -l 9=97 marc21.raw >marc21.utf8.raw
The same records may be converted to MARCXML instead in UTF-8:
yaz-marcdump -f MARC-8 -t UTF-8 -o marcxml marc21.raw >marcxml.xml
Turbo MARC is a compact XML notation with same semantics as MARCXML, but which allows for faster processing via XSLT. In order to generate Turbo MARC records encoded in UTF-8 from MARC21 (ISO), one could use:
yaz-marcdump -f MARC8 -t UTF8 -o turbomarc -i marc marc21.raw >out.xml