Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I extract a subtree from a Gedcom file? #136

Open
viniciostorres opened this issue Oct 11, 2023 · 2 comments
Open

How can I extract a subtree from a Gedcom file? #136

viniciostorres opened this issue Oct 11, 2023 · 2 comments

Comments

@viniciostorres
Copy link

viniciostorres commented Oct 11, 2023

Tanks for excelent c# library for Gedcom. I think this is the best library I found to this.

I have a Gedcom file exported from MyHeritage that have hundreds of Individuals and Families. I want to export only a specific family to a new Gedcom file.
I open the original file and select the individuals I need and added to new database.

But when I write a new Gedcom using GedcomRecordWriter.OutputGedcom(exportGedcom, "Rewritten.ged"); I get the error:

Exception has occurred: CLR/System.NullReferenceException
An unhandled exception of type 'System.NullReferenceException' occurred in GeneGenie.Gedcom.dll: 'Object reference not set to an instance of an object.'
   at GeneGenie.Gedcom.Parser.GedcomRecordWriter.Write(GedcomDatabase database, GedcomStreamWriter writer) in /home/vinicios/workspace/GeneGenie.Gedcom/GeneGenie.Gedcom/Parser/GedcomRecordWriter.cs:line 161

What I need to do to build a valid new Gedcom using informations from another Gedcom file?

Thanks again,

Vinicios Torres

@RyanONeill1970
Copy link
Member

I'll have to look into it, would you be able to share the data file that caused the error? You could email it to me if needed (r@genegenie.com).

@viniciostorres
Copy link
Author

HI, Ryan,

I have found some issues, I think. First, it is not enough to create new GedcomDatabase using:

var exportGedcom = new GedcomDatabase();

It have generated null exception because the abscence of Header. So, to solve that I created a gedcom file with just header to be a base of new database.

And I discovered that I must use:

exportGedcom.Add( individual.XRefID, individual);

to add an imported person (and events, photos, families) to new database. Initially I thought I should use exportGedcom.Individuals.Add(individual);

I will continue testing here and then report back to you my experience with the library.

Tahks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants