Read and write GEDCOM 7 files in Python — a format for exchanging genealogical data between family history applications.
Reading and writing are both based on regular expressions generated directly from the ABNF grammar via abnf-to-regexp, and on the structure and payload tables extracted from the specification. The library targets FamilySearch GEDCOM 7.0.18: it does not attempt to parse files that are not standards compliant, and raises rather than writing malformed lines.
python -m pip install gedcom7
import gedcom7
with open("my_gedcom.ged", "rb") as f:
records = gedcom7.load(f)
with open("out.ged", "wb") as f:
gedcom7.dump(records, f)Each record is a GedcomStructure with a tag, an optional xref and pointer, the raw text payload, and children. Its value property casts the payload to the data type the specification gives that structure type.
loads and dumps are the string equivalents. Non-conforming input raises GedcomParseError, a ValueError carrying line_number.
python -m pip install --group dev --editable .
pytest && mypy && ruff check . && ruff format --check .
The version is derived from git tags by setuptools-scm. To release, push a vX.Y.Z tag and publish a GitHub release for it.
Inspiration was drawn from the Javascript parser.