Skip to main content

A lightweight tool to parse, browse and edit gedcom files.

Project description

FastGedcom

A lightweight tool to parse, browse and edit gedcom files.

Install FastGedcom using pip from its PyPI page:

pip install fastgedcom

To install the Ansel codecs use the following command. It enables the use of the Ansel text encoding often used for gedcom files.

pip install fastgedcom[ansel]

Why choosing FastGedcom?

  • FastGedcom has less methods, which make it easier to work with.
  • FastGedcom has a linear syntax, if blocks are less needed.
  • FastGedcom is shorter to write with the use of operator overloading. (optional)
  • FastGedcom has a faster parsing.
Gedcom file FastGedcom Other Libraries

0 HEAD
0 @I1@ INDI
1 NAME John Doe
1 BIRT
2 DATE 1 Jan 1970
1 DEAT
2 DATE 2 Feb 2081
0 TRLR
		
		

# Faster parsing
document = strict_parse("my-file.ged")
person = document["@I1@"]
# No if chain!
death = person.get_sub_line("DEAT")
date = death.get_sub_line("DATE")
print(date.payload)
# Prints None if the field is missing
		

# With the python-gedcom library
document = Parser("my-file.ged")
person = document.get_element_dictionary()["@I1@"]
death_data = person.get_death_data()
if death_date[1]:
	date = death_date[1]
	if date:
		print(date)
		

Features

The least abstraction from gedcom with free choice of formatting

There is a lot of genealogy software out there, and every one of them have its own tags and formats to write information. With the FastGedcom approach, you can easily adapt your code to your gedcom files.

from fastgedcom.parser import strict_parse
from fastgedcom.helpers import extract_name_parts

document = strict_parse("gedcom_file.ged")

name = document["@I1@"] >= "NAME"
print(name) # Unformatted
given_name, surname = extract_name_parts(name)
print(f"{given_name.capitalize()} {surname.upper()}")

Multi-encoding support

It supports gedcom files encoded in UTF-8 (with and without BOM), UTF-16 (also named UNICODE), ANSI, and ANSEL.

This Option paradigm replaces the if blocks:

If a field is missing, you will get a FakeLine containing an empty string. This helps reduce the boilerplate code massively. And, you can differentiate a TrueLine from a FakeLine with a simple boolean check.

indi = document["@I13@"]

# You can access the date of death, whether the person is deceased or not.
date = (indi > "DEAT") >= "DATE"

# You choose the formatting of the date
print("Death date:", format_date(date))

Typehints for salvation!

Autocompletion and type checking make development so much easier.

Why it is called FastGedcom?

FastGedcom's aim is to keep the code close to your gedcom files. So, you don't have to learn what FastGedcom does. The data you have is the data you get. The content of the gedcom file is unchanged and there is no abstraction. Hence, the learning curve of the library is faster than the alternatives. The data processing is optional to best suit your needs. FastGedcom is more of a starting point for your data processing than a feature-rich library.

The name FastGedcom doesn't just come from its ease of use. Parsing is the fastest among Python libraries. Especially for parsing and getting the relatives of a person, the FamilyLink class is build for this purpose. Here are the benchmarks.

Documentation and examples

Want to see more of FastGedcom? Here are some examples

The documentation of FastGedcom is available on ReadTheDocs.

Feedback

Comments and contributions are welcomed, and they will be greatly appreciated!

If you like this project, consider putting a star on GitHub. Thank you!

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastgedcom-1.1.0.tar.gz (21.2 kB view hashes)

Uploaded Source

Built Distribution

fastgedcom-1.1.0-py3-none-any.whl (15.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page