gedcom7
A GEDCOM 7 parser for Python.
Background
The parser is 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. It
targets FamilySearch GEDCOM
7.0.18.
It does not attempt to parse files that are not standards compliant: a data
stream that violates the specification raises GedcomParseError rather than
being partially or silently misparsed.
Installation
python -m pip install gedcom7
Usage
import gedcom7
with open("my_gedcom.ged", "r", encoding="utf-8") as f:
string = f.read()
records = gedcom7.loads(string)
Each record is a GedcomStructure with a tag, an optional xref and
pointer, the raw text payload, and children. The value property casts the
payload to the data type the specification gives that structure type:
indi = records[1] # 0 @I1@ INDI
birt = indi.children[0] # 1 BIRT
date = birt.children[0] # 2 DATE 1 JAN 2000
date.type_id # 'https://gedcom.io/terms/v7/DATE'
date.value # Date(calendar=None, day=1, month='JAN', ...)
value is None where a structure has no payload, and the payload is returned
uninterpreted where the structure type is defined by an extension rather than by
the specification.
Errors
loads raises GedcomParseError (a subclass of ValueError) for any data
stream that does not conform to the specification, reporting where the problem
is:
from gedcom7 import GedcomParseError
try:
records = gedcom7.loads(string)
except GedcomParseError as exc:
print(exc) # line 42: malformed line: '1 NOTE @invalid'
print(exc.line_number) # 42
print(exc.line) # "1 NOTE @invalid"
This covers malformed lines, prohibited level sequences, banned characters,
misplaced CONT continuations, duplicate or misplaced cross-reference
identifiers, pointers that resolve to nothing, and a missing header or trailer.
Development
Install the package together with the development dependencies:
python -m pip install --group dev --editable .
Then run the checks:
pytest # tests
mypy # static type check (strict)
ruff check . # lint
ruff format . # format
Releasing
The version is derived from git tags by
setuptools-scm; there is no version
string in the source tree. To release, push a vX.Y.Z tag and publish a GitHub
release for it — the PyPI deploy workflow builds the distributions and
uploads them via PyPI trusted publishing.
Credits
Inspiration was drawn from the Javascript parser.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gedcom7-0.5.0.tar.gz.
File metadata
- Download URL: gedcom7-0.5.0.tar.gz
- Upload date:
- Size: 37.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c1b41dc4a69dfcd11853c4f63a073e2edae9352d49bbfaeb3eb123aa520a5bf
|
|
| MD5 |
5a469b7cdd02d52a9fdccc0b8f4b6fa1
|
|
| BLAKE2b-256 |
955b9e27c796f29e1f15da368be5fbb5f3bd01fc1225d294c11afe0cc53bd31b
|
Provenance
The following attestation bundles were made for gedcom7-0.5.0.tar.gz:
Publisher:
pypi.yml on DavidMStraub/python-gedcom7
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gedcom7-0.5.0.tar.gz -
Subject digest:
4c1b41dc4a69dfcd11853c4f63a073e2edae9352d49bbfaeb3eb123aa520a5bf - Sigstore transparency entry: 2437452194
- Sigstore integration time:
-
Permalink:
DavidMStraub/python-gedcom7@ad3941a28b6919775625a2925b2be57cb2c01179 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/DavidMStraub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@ad3941a28b6919775625a2925b2be57cb2c01179 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gedcom7-0.5.0-py3-none-any.whl.
File metadata
- Download URL: gedcom7-0.5.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20f588e482e342d6aa52c1b2eae0a71a51133aaea449bb474dc10649e579dba5
|
|
| MD5 |
e45cf10f6e0fcfacfe4518f00f61816e
|
|
| BLAKE2b-256 |
825d9e88fe6bd654cdb3d0460ee8a8f5b16dc1ceb5a35ea35910189c1c2b53eb
|
Provenance
The following attestation bundles were made for gedcom7-0.5.0-py3-none-any.whl:
Publisher:
pypi.yml on DavidMStraub/python-gedcom7
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gedcom7-0.5.0-py3-none-any.whl -
Subject digest:
20f588e482e342d6aa52c1b2eae0a71a51133aaea449bb474dc10649e579dba5 - Sigstore transparency entry: 2437452263
- Sigstore integration time:
-
Permalink:
DavidMStraub/python-gedcom7@ad3941a28b6919775625a2925b2be57cb2c01179 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/DavidMStraub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@ad3941a28b6919775625a2925b2be57cb2c01179 -
Trigger Event:
release
-
Statement type: