Creating an album or exporting records via Python script

16 views
Skip to first unread message

Jay Fletcher

unread,
Mar 25, 2025, 10:31:35 AMMar 25
to GEDitCOM II Discussions
I've written a Python script leveraging the GEDitCOM II Python script support to sort through my GEDCOM and identify a subset of individuals. Now I would like to either put those individuals in a new album or export them to a new GEDCOM. However, each of the functions I would like to use (addAlbum, CreateDocument,  delete, difference, intersection) are listed in the help file as "internal script use only."

I have a list of record identifiers for the individuals that I would like to put in a new album or export to a new GEDCOM. Can you recommend how I can do this from within my Python script?

Thank you,
Jay

John Nairn, Developer

unread,
Apr 9, 2025, 1:19:10 PMApr 9
to GEDitCOM II Discussions
First, I would recommend using an internal script instead. It is 5-10X faster than Python. More importantly, it avoids possible future when Apple discontinues support for Python interacting with applications (It has already do that for Apps in the App Store).

You can still use Python and you can add albums and more. For example, see GEDitCOM Editor help on writing extensions and the section on "Writing Python Scripts." It has a section on working with albums (e.g., with move to album and delete from album). The section on that page also as "Working with Genealogy Documents" that gives example of creating a new document.

While I am sure Python can do anything you want, some things require knowing details about MacOS programming and not just Python. For example, document creation uses the awkward

     newdoc = gedit.classForScriptingClass_("document").alloc().init()

I tried to add some of these things for myself in the GEDitCOMII.py module that comes with GEDitCOM II. It has lots of utility functions to help in Python programming and tries to had MacOS things within python def functions. The module even has many undocumented utilities (things I needed for some scripts but did not know if they would be of general use). When working with Albums, you might look through the RecordSet class in the Python module. You can add records to that class, do python things like union, difference, etc, and and then latter add to album, move to new document, export as GEDCOM file, or more. It is all possible Python, if not easy. Much of it is now easier in internal scripting. It does mean a new language, but if you know Python it should bot be difficult to use. I am finishing up some new feature to make even easier (with some python like adjustment).

Note that Python module is partially documented in GEDitCOM Editor help. To see more, open the module in the GEDitCOM Editor Scripting Workspace.

John Nairn
Reply all
Reply to author
Forward
0 new messages