# Export Gramps to Myheritage with married surname

**URL:** https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297
**Category:** Development
**Tags:** uuid
**Created:** [October 22, 2024, 8:03pm UTC](https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297 "2024-10-22T20:03:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Urchello](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@Urchello](https://gramps.discourse.group/u/Urchello)
#### Post date: [October 22, 2024, 8:03pm UTC](https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297/1 "2024-10-22T20:03:56Z")

</div>

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

 ![Screenshot from 2024-10-23 10-20-39](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/1/16f1d6483190c94d8df130af1b4778d89f73d763.png)

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

This code fragment:

```python
        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:

```python
        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.

 ![Screenshot from 2024-10-23 10-20-06](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/d/d468013f68e3d8348f030414bfb950b8f7def98d.png)

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?**

---

<div class="post-metadata">

### Author: ![anon44746896](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@anon44746896](https://gramps.discourse.group/u/anon44746896)
#### Post date: [October 23, 2024, 7:28am UTC](https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297/2 "2024-10-23T07:28:36Z")

</div>

> [@Urchello](#):
>
> To reach this we need make some changes here: `/gramps/plugins/export/exportgedcom.py`

Instead of doing that you should added it as an option in the [Addon GEDCOM extensions](https://www.gramps-project.org/wiki/index.php/Addon:GEDCOM_Extensions) which is for unofficial GEDCOM extensions which extend Gramps GedcomWriter to include common non-compliant GEDCOM additions kike Myheritage.

---

<div class="post-metadata">

### Author: ![Urchello](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@Urchello](https://gramps.discourse.group/u/Urchello)
#### Post date: [October 23, 2024, 7:29am UTC](https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297/3 "2024-10-23T07:29:43Z")

</div>

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

 ![Screenshot from 2024-10-23 10-30-45](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/0/01bb26b9a9d62ca429b9242d41b86a296770e7e9.png)

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:

```python
- # 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):

```python
+ 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)

```

 ![Screenshot from 2024-10-23 10-10-56](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/6/6c7df48c8a8fbf01b03c79abb844b0fc70d51f6d.png)

---

<div class="post-metadata">

### Author: ![Urchello](https://avatars.discourse-cdn.com/v4/letter/u/c4cdca/32.png) [@Urchello](https://gramps.discourse.group/u/Urchello)
#### Post date: [October 23, 2024, 7:33am UTC](https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297/4 "2024-10-23T07:33:00Z")

</div>

> [@anon44746896](#):
>
> Instead of doing that you should added it as an option in the [Addon GEDCOM extensions](https://www.gramps-project.org/wiki/index.php/Addon:GEDCOM_Extensions)

Thank you a lot! I will try it

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)
#### Post date: [November 22, 2024, 7:33am UTC](https://gramps.discourse.group/t/export-gramps-to-myheritage-with-married-surname/6297/5 "2024-11-22T07:33:34Z")

</div>

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