Skip to content

Python script to fix MARC21 indicators in batch records #995

Description

@melzalabany

Summary

Create a Python script to fix MARC21 indicators in batch-processed records.

Details

  • The script processes a file containing MARC21 records in standard format.
  • For each tag with indicators, ensures there are exactly two indicators after the 3-digit tag (pads with spaces if missing or incomplete).
  • Fields that do not use indicators (such as =LDR, =001, =005, =008) remain unchanged.
  • Output is a corrected version of the MARC file, suitable for use with migration tools.
  • Example input and output provided in the discussion.

Example usage

  1. Save MARC records to marc_records.txt.
  2. Run the script: python fix_marc_indicators.py
  3. Output is saved as marc_records_fixed.txt with corrected indicators.

Implementation

The script uses regex to identify and fix indicators. See user prompt for example input data and further details.


Let me know if you need the script as a PR or want additional enhancements!

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonPull requests that update python code

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions