Export Gramps to Myheritage with married surname

By default Myheritage can not import married surname from Gramps gedcom exports.

To reach this we need make some changes here: /gramps/plugins/export/exportgedcom.py

This code fragment:

        self._writeln(1, "NAME", gedcom_name)
        if int(name.get_type()) == NameType.BIRTH:
            self._writeln(2, "TYPE", "birth")
        elif int(name.get_type()) == NameType.MARRIED:
            self._writeln(2, "TYPE", "married")
        elif int(name.get_type()) == NameType.AKA:
            self._writeln(2, "TYPE", "aka")
        else:
            self._writeln(2, "TYPE", name.get_type().xml_str())

        if firstname:
            self._writeln(2, "GIVN", firstname)
        if surprefix:
            self._writeln(2, "SPFX", surprefix)
        if surname:
            self._writeln(2, "SURN", surname)
        if call:
            self._writeln(2, "_RUFNAME", call)
        if name.get_suffix():
            self._writeln(2, "NSFX", suffix)
        if name.get_title():
            self._writeln(2, "NPFX", title)
        if nick:
            self._writeln(2, "NICK", nick)

should be replased with this one:

        if int(name.get_type()) == NameType.BIRTH:
            self._writeln(1, "NAME", gedcom_name)
            if firstname:
                self._writeln(2, "GIVN", firstname)
            if surname:
                self._writeln(2, "SURN", surname)
        elif int(name.get_type()) == NameType.MARRIED:
            self._writeln(2, "_MARNM", gedcom_name)

        if surprefix:
            self._writeln(2, "SPFX", surprefix)
        if call:
            self._writeln(2, "_RUFNAME", call)
        if name.get_suffix():
            self._writeln(2, "NSFX", suffix)
        if name.get_title():
            self._writeln(2, "NPFX", title)
        if nick:
            self._writeln(2, "NICK", nick)

I tested it with one person only, it works.

Pay attention that I removed AKA and unknown types. Looks like Myheritage doesnt use them. Anyway it would be greate if anybody confirm or correct the above code.

Lets collect such fragments and and later implement individual exports/imports between different external services and Gramps?

Instead of doing that you should added it as an option in the Addon GEDCOM extensions which is for unofficial GEDCOM extensions which extend Gramps GedcomWriter to include common non-compliant GEDCOM additions kike Myheritage.

Another one thing. Almost all my media have attributes like “URL”, “Familysearch URL”.

Myheritage doesnt receive them via GEDCOM. But it has “URL” field for sources (citations in Gramps). If anybody needs move media urls into a proper field of myheritage, you can make these changes here /usr/local/lib/python3.10/dist-packages/gramps/plugins/export/exportgedcom.py (row 1461):

instead of this:

-        # Reference to the source
-        self._writeln(level, "SOUR", "@%s@" % src.get_gramps_id())
-        if citation.get_page() != "":
-            # PAGE <WHERE_WITHIN_SOURCE> can not have CONC lines.
-            # WHERE_WITHIN_SOURCE:= {Size=1:248}
-            # Maximize line to 248 and set limit to 248, for no line split
-            self._writeln(level + 1, "PAGE", citation.get_page()[0:248], limit=248)

use something like this (but correct for four needs):

+        page_str = ""    
+        found = False
+        media_list = citation.get_media_list()
+        for media in media_list:
+            media_handle = media.get_reference_handle()
+            if media_handle and isinstance(media_handle, str):
+                media = self.dbase.get_media_from_handle(media_handle)
+                if media:
+                    for attr in media.get_attribute_list():
+                        if "url" in str(attr.get_type()).lower():
+                            page_str = attr.get_value()
+                            found = True
+                            break
+            if found:
+                break
+                if page_str == "":
+                    page_str = citation.get_page()+

+        # Reference to the source
+        self._writeln(level, "SOUR", "@%s@" % src.get_gramps_id())
+        if page_str != "":
+            # PAGE <WHERE_WITHIN_SOURCE> can not have CONC lines.
+            # WHERE_WITHIN_SOURCE:= {Size=1:248}
+            # Maximize line to 248 and set limit to 248, for no line split
+            # But Myheritage supports up to 255 characters
+            self._writeln(level + 1, "PAGE", page_str[0:255], limit=255)

Thank you a lot! I will try it

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.