Skip to main content

FastGedcom

A gedcom tool to parse, browse and modify gedcom files

Installation

You can install FastGedcom using pip:

pip install fastgedcom

The ansel library is a dependancy of FastGedcom. It is automatically installed by pip. This library allows to decode files encoded in ansel or gedcom.

Features

  • Supports the read of gedcom files encoded in UTF-8 with and without BOM, UTF-16 (also named UNICODE), ANSI, and ANSEL.

  • Supports the export to gedcom files encoded in UTF-8, UTF-16, and ANSI.

  • The gedcom representation (the data structure) is very lite (2 classes overall).

  • No data parsing is done (due to the wide diversity), but helper methods are provided.

Motivations

The FastGedcom library is intented to be read, understood, and used quickly, so you focus on what really matters. The code has type hints to help with development. Functions are based directly on gedcom pointers for ease of use. Due to the wide variety of gedcom software, no data parsing is done, but some standalone functions are provided (see the gedcom_helper module).

Usage examples

In the following example, we print the name of the person under the reference @I1@.

from fastgedcom.gedcom_parser import guess_encoding, parse

gedcom_file = "your_gedcom_file"
with open(gedcom_file, "r", encoding=guess_encoding(gedcom_file)) as f:
	gedcom, warnings = parse(f)
print("Warnings:", *warnings, sep="\n", end="---\n")

indi = gedcom.get_record("@I1@")
assert(indi)
name = indi.get_sub_record_payload("NAME")
print(name)

In the following example, we count the number of ancestral generations of the person whose reference is @I1@.

from fastgedcom.gedcom_parser import guess_encoding, parse
from fastgedcom.gedcom_structure import IndiRef

gedcom_file = "fastgedcom/test/test_data/bouyer-perret 20220809.ged"
with open(gedcom_file, "r", encoding=guess_encoding(gedcom_file)) as f:
	gedcom, _ = parse(f)

def nb_ancestral_gen(indi: IndiRef) -> int:
	father, mother = gedcom.get_parents(indi)
	father_gens = 0 if father is None else 1+nb_ancestral_gen(father)
	mother_gens = 0 if mother is None else 1+nb_ancestral_gen(mother)
	return max(1, father_gens, mother_gens)

number_generations_above_root = nb_ancestral_gen("@I1@")

print(f"Number of generations above root: {number_generations_above_root}")

In the following example, we find the oldest deceased person. Then, we print his name and all his gedcom information using the gedcom_helper module

from fastgedcom.gedcom_helper import (extract_int_year, extract_year,
                                      get_birth_date, get_death_date,
                                      get_gedcom_data, get_name)
from fastgedcom.gedcom_parser import guess_encoding, parse

gedcom_file = "your_gedcom_file"
with open(gedcom_file, "r", encoding=guess_encoding(gedcom_file)) as f:
	gedcom, _ = parse(f)

oldest = next(gedcom.get_records("INDI")).tag
age_oldest = 0.0 # the age is a float to handle all type of date
# A date such as between 2001 and 2002 returns 2001.5
for individual in gedcom.get_records("INDI"):
	birth_date = get_birth_date(gedcom, individual.tag)
	death_date = get_death_date(gedcom, individual.tag)
	birth_year = extract_int_year(birth_date)
	death_year = extract_int_year(death_date)
	if birth_year is None or death_year is None: continue
	age = death_year - birth_year
	if age > age_oldest:
		oldest = individual.tag
		age_oldest = age

print("Oldest person:", get_name(gedcom, oldest))
print("Year of birth:", extract_year(get_birth_date(gedcom, oldest)))
print("Year of death:", extract_year(get_death_date(gedcom, oldest)))
print("Age:", age_oldest)
print("All the information:", get_gedcom_data(gedcom, oldest))

Contributing

Contributions are welcome, and they will be greatly appreciated!

If you like this project, consider putting a star on Github, thank you!

For any feedback or question, please feel free to contact me by email at gatien.bouyer.dev@gmail.com or via Github issues.

Metadata

Release files for fastgedcom 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastgedcom 0.0.1
File Size Uploaded
fastgedcom-0.0.1.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastgedcom 0.0.1
File Interpreter ABI Platform
fastgedcom-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / fastgedcom-0.0.1.tar.gz

Download URL fastgedcom-0.0.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ed2c5be588aad32b3b8b630ebf6ba3dc74b500c500d33b30408ed91fc62f493d
BLAKE2b-256 checksum
How to use checksums
dce316df96e90b5514a31950d7ad9d3b7be70fc884b59287d4bbbc4d5884ef00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / fastgedcom-0.0.1-py3-none-any.whl

Download URL fastgedcom-0.0.1-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98fb23061d48456390e741fdc9e5aada6d44a82618e87f399a76549ddaac57cb
BLAKE2b-256 checksum
How to use checksums
437cfd3f1cd512aecfa72fbaa9aa31d840be7d4903fc31abe30e22f83184a2d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page