Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 199827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:03:27+00:00 2026-05-11T17:03:27+00:00

Does anyone know of a good class to read in .ged files Gedcom is

  • 0

Does anyone know of a good class to read in .ged files

Gedcom is a file format that is used to store genealogical information.

My goal is to write something that would let me import a ged file and export a .dot file for graphviz so that I can make a visual representation of a family tree

thanks if you can help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:03:27+00:00Added an answer on May 11, 2026 at 5:03 pm

    Heres my best attempt so far.

    It seems to be working for what i need though its defiently not full proof ( then again my family tree is rather large and that adds some complexity)

    please let me know if you think i could make anything more elequient

    struct INDI
            {
                public string ID;
                public string Name;
                public string Sex;
                public string BirthDay;
                public bool Dead;
    
    
            }
            struct FAM
            {
                public string FamID;
                public string type;
                public string IndiID;
            }
            List<INDI> Individuals = new List<INDI>();
            List<FAM> Family = new List<FAM>();
            private void button1_Click(object sender, EventArgs e)
            {
                string path = @"C:\mostrecent.ged";
                ParseGedcom(path);
            }
    
            private void ParseGedcom(string path)
            {
                //Open path to GED file
                StreamReader SR = new StreamReader(path);
    
                //Read entire block and then plit on 0 @ for individuals and familys (no other info is needed for this instance)
                string[] Holder = SR.ReadToEnd().Replace("0 @", "\u0646").Split('\u0646');
    
                //For each new cell in the holder array look for Individuals and familys
                foreach (string Node in Holder)
                {
    
                    //Sub Split the string on the returns to get a true block of info
                    string[] SubNode = Node.Replace("\r\n", "\r").Split('\r');
                    //If a individual is found
                    if (SubNode[0].Contains("INDI"))
                    {
                        //Create new Structure
                        INDI I = new INDI();
                        //Add the ID number and remove extra formating
                        I.ID = SubNode[0].Replace("@", "").Replace(" INDI", "").Trim();
                        //Find the name remove extra formating for last name
                        I.Name = SubNode[FindIndexinArray(SubNode, "NAME")].Replace("1 NAME", "").Replace("/", "").Trim(); 
                        //Find Sex and remove extra formating
                        I.Sex = SubNode[FindIndexinArray(SubNode, "SEX")].Replace("1 SEX ", "").Trim();
    
                        //Deterine if there is a brithday -1 means no
                        if (FindIndexinArray(SubNode, "1 BIRT ") != -1)
                        {
                            // add birthday to Struct 
                            I.BirthDay = SubNode[FindIndexinArray(SubNode, "1 BIRT ") + 1].Replace("2 DATE ", "").Trim();
                        }
    
                        // deterimin if there is a death tag will return -1 if not found
                        if (FindIndexinArray(SubNode, "1 DEAT ") != -1)
                        {
                            //convert Y or N to true or false ( defaults to False so no need to change unless Y is found.
                            if (SubNode[FindIndexinArray(SubNode, "1 DEAT ")].Replace("1 DEAT ", "").Trim() == "Y")
                            {
                                //set death
                                I.Dead = true;
                            }
                        }
                        //add the Struct to the list for later use
                        Individuals.Add(I);
                    }
    
                    // Start Family section
                    else if (SubNode[0].Contains("FAM"))
                    {
                        //grab Fam id from node early on to keep from doing it over and over
                        string FamID = SubNode[0].Replace("@ FAM", "");
    
                        // Multiple children can exist for each family so this section had to be a bit more dynaimic
    
                        // Look at each line of node
                        foreach (string Line in SubNode)
                        {
                            // If node is HUSB
                            if (Line.Contains("1 HUSB "))
                            {
    
                                FAM F = new FAM();
                                F.FamID = FamID;
                                F.type = "PAR";
                                F.IndiID = Line.Replace("1 HUSB ", "").Replace("@","").Trim();
                                Family.Add(F);
                            }
                                //If node for Wife
                            else if (Line.Contains("1 WIFE "))
                            {
                                FAM F = new FAM();
                                F.FamID = FamID;
                                F.type = "PAR";
                                F.IndiID = Line.Replace("1 WIFE ", "").Replace("@", "").Trim();
                                Family.Add(F);
                            }
                                //if node for multi children
                            else if (Line.Contains("1 CHIL "))
                            {
                                FAM F = new FAM();
                                 F.FamID = FamID;
                                F.type = "CHIL";
                                F.IndiID = Line.Replace("1 CHIL ", "").Replace("@", "");
                                Family.Add(F);
                            }
                        }
                    }
                }
            }
    
            private int FindIndexinArray(string[] Arr, string search)
            {
                int Val = -1;
                for (int i = 0; i < Arr.Length; i++)
                {
                    if (Arr[i].Contains(search))
                    {
                        Val = i;
                    }
                }
                return Val;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know a good C++ class to read (and possibly also write) INI
Does anyone know a good helper class for stageVideo with as3 that works well
Does anyone know of a good tool for laying out class diagrams and the
Does anyone know of a log4j or logback class that can redact passwords based
Does anyone know of a good .NET library that allows me to parse source
Does anyone know of any good references for Microsofts configuration files. I always need
Does anyone know good example of using CSS to create rounded corner box where:
Does anyone know a good place to look for basic principles and tutorials on
Does anyone know any good resources with tasks or problems to get practice in
Does anyone know a good way to test if one element, stored in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.