3

I've found an old GEDCOM file of mine where I did not mark many ancestors as dead despite their birth lying back over a hundred years.

Is there an easy way to automatically mark them as dead (with unkown date) instead of manually modifying each individual entry?

What complicates matters further is the lack of birth years (let alone dates) of even older generations, so the magic tool would ideally also have to recognise descendants born after 1900 (or any other given year, of course) and logically conclude their ancestor's death. And going down other branches gets even more complicated if no birth years are present at all in them.

2
  • Some programs have this as a built-in option. Apr 28 at 0:14
  • @RichardPetersen76 Please feel free to name some as answer, that might already do the trick ;) Apr 29 at 7:57
2

As a Gedcom file is just plain text you can easily modify it with a plain text editor such as the free Notepad++. If you do get Notepad++ it also has a free addon Gedcom parser.

You can then do a complicated search and replace looking for a 1 BIRT look at the 2 DATE that comes after it get the year part from the date then check if there is a 1 DEAT with a 2 DATE and if not then create one. You would need to do this for each person in the Gedcom. Notepad++ does have Regex search and replace so you could create an automatic search and replace if you understand Regex. I would suggest that this is probably not the best way to do it as it is likely to be error prone.

I know you said you wanted to do this automatically rather than individually but probably a better way would be to use the free version of one of the genealogy programs such as Legacy Family Tree, Ancestral Quest or Gramps (there are others). Import your gedcom into that program and use its functionality to step through each individual and add a death if appropriate. Some programs such as Family Historian (paid for) allow plugins to run and there may be a suitable plugin that would automatically do what you want.

1
1

I've written a small Python script for this, also trying to estimate each individual's birth date based on their relatives, at https://github.com/zommuter/gedcom-reaper-py, where feedback can be provided using its issues page.

Here's a raw dump of the initial version:

#!/usr/bin/env python
# coding: utf-8

import sys
import gedcom.parser
from gedcom.element.individual import IndividualElement



gedcom_parser = gedcom.parser.Parser()
gedcom_parser.parse_file(sys.argv[1])
root_elements = gedcom_parser.get_root_child_elements()

dct = gedcom_parser.get_element_dictionary()

def get_kids(individual):
    kids = []
    for child in individual.get_child_elements():
        if child.get_tag() == gedcom.tags.GEDCOM_TAG_FAMILY_SPOUSE:
            family_id = child.get_value()
            family = dct[family_id]
            #print(family.to_gedcom_string(recursive=True))
            for children in family.get_child_elements():
                #print(children.get_tag())
                if children.get_tag() == gedcom.tags.GEDCOM_TAG_CHILD:
                    kids.append(dct[children.get_value()])
    
    return kids

def get_parents(individual):
    parents = []
    for child in individual.get_child_elements():
        if child.get_tag() == gedcom.tags.GEDCOM_TAG_FAMILY_CHILD:
            family_id = child.get_value()
            family = dct[family_id]
            #print(family.to_gedcom_string(recursive=True))
            for element in family.get_child_elements():
                if element.get_tag() in (gedcom.tags.GEDCOM_TAG_HUSBAND, gedcom.tags.GEDCOM_TAG_WIFE):
                    parents.append(dct[element.get_value()])
                    
    return parents
            
def get_latest_possible_birth_year(individual, add_per_generation=10, max_per_generation=50, checked=None):
    checked = [] if checked is None else checked
    #year = -1  # Rather bad idea assumung one day genealogy might reach back to 1 BC
    #print(individual.get_name(), individual.get_birth_year())
    year = individual.get_birth_year()
    checked.append(individual)
    if year == -1:  # i.e. none, that's not a good feature of python-gedcom
        kids = get_kids(individual)
        #print(kids)
        year = 9999  # that's just as bad...
        for kid in kids:
            if kid in checked:  # prevent infinite recursion
                continue
            kid_year = get_latest_possible_birth_year(
                           kid,
                           add_per_generation=add_per_generation,
                           max_per_generation=max_per_generation,
                           checked=checked
                           )
            if -1 < kid_year < 9000:
                year = min(year, kid_year - add_per_generation)
    # not enough information about kids? check their parents then and assume no more than max_per_generation years difference
    if year > 9000:  # still too magical...
        year = -9999  # magic numbers all around...
        parents = get_parents(individual)
        for parent in parents:
            if parent in checked:  # prevent infinite recursion
                continue
            parent_year = get_latest_possible_birth_year(
                           parent,
                           add_per_generation=add_per_generation,
                           max_per_generation=max_per_generation,
                           checked=checked
                           )
            if -1 < parent_year < 9000:
                year = max(year, parent_year + max_per_generation)
        if year >= 9000 or year <= -1:
            year = -1  # still no luck then...
        
    return year

# now the magic...
print("The following entries will be updated to dead based on their estimated death date")
for index, element in enumerate(root_elements):
    if isinstance(element, IndividualElement):
        if not element.is_deceased() and get_latest_possible_birth_year(element) <= 1900:
            print(index, element.get_pointer(), element.get_name(), element.get_birth_data())
            element.new_child_element(gedcom.tags.GEDCOM_TAG_DEATH)

# python-gedcom's .to_gedcom_string(recursive=True) seems to fail misearbly at nested levels
def recustr(element):
    recstr = element.to_gedcom_string()
    recstr = recstr + ''.join([recustr(child) for child in element.get_child_elements()])
    return recstr

print(recustr(gedcom_parser.get_root_element()))
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.