A Python library for reading, writing, and modifying MARC (MAchine-Readable Cataloging) bibliographic data. It supports reading MARC21 from files or strings and writing records in various formats including MARC-8, UTF-8, and XML. Current version 5.3.1, requires Python >=3.9. Released under MIT license.
pip install pymarcNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Open a MARC file, iterate records, print title and author; create a new record and output raw MARC.
Upgrade Python to 3.9+ or stick with pymarc <5.0 if on Python 3.8.
Use MARCReader(fh, strict=False) for tolerant reading.
Open output files in binary mode 'wb' when writing as_marc().
Use field.get_subfields('a') to get list of values for a given subfield code.Use open('file.mrc', 'rb') when reading MARC binary files.Use encoding='utf-8' explicitly or convert file to UTF-8. For MARC-8, pymarc handles it internally if read as bytes.
Check if field exists: title = record['245']; if title: print(title.value()).
Use 'from pymarc import Record' (it's exported in __init__.py).
No dependency data recorded yet.
No resource links recorded.