Skip to content

Instantly share code, notes, and snippets.

@martinlovell
martinlovell / parse_marc.py
Last active October 7, 2025 15:54
PyMarc example supporting multiple formats (XML, MARC21 binary, JSON).
"""
MARC record parser supporting multiple formats (XML, MARC21 binary, JSON).
This script demonstrates how to use the pymarc library to parse MARC records
from various file formats and extract record identifiers.
"""
from pymarc import XmlHandler, parse_xml, MARCReader, JSONReader
import tarfile
import argparse