Has anyone a Gedcom Parser?

derez

Expert
Licensed User
Longtime User
Of course, look at the 1.ged file.
Therte is I1,F1,O1 etc.
also I2,F2,...

The file is built in main block of Family, which details the identifiers of the Husband, wife, children and datails of marriage like date.
Then there is the block of individual (INDI)
then there are Objects, like a photo, with details of the type of object, file name etc.
There are Notes (N#) and Sources, (S#).

So, since usually you want to show all the data of one person in one form, you need to be able to refer to all at the same display.

What I did - I added a "next" button which show the next tree of the same person, and fills the missing elements from the recieving textboxes of my tree, But this is not the right way. I think the best is to create a higher level of tree root, which refers to the person number, and under it all the various trees of the same number but different letters.
 

derez

Expert
Licensed User
Longtime User
I'm not sure I know what you mean.

If you look at post #11 you'll see that my application's database contains items which can be found in several trees, not in one tree of the GEDCOM file. For example - the items Father, Mother, Spouse are names, and to get them I have to look at two trees called FAMC and FAMS, from there to get the names of wife, father and mother. The notes are kept in a text file with the name as the ID number, so I have to look at the tree of Notes, etc.

The way I see it, I have to move the items partly automatic and partly manual , and after all is put into textboxes, I give new ID codes to fit to my numbering system and store to my database. This is done person by person because I do not intend to add the whole file.
 

derez

Expert
Licensed User
Longtime User
With this mod I get the blocks of data on one tree.
B4X:
Sub ComboBox1_SelectionChanged (Index, Value)
   treeg.RemoveAllNodes   ' here instead of in the showkeytree sub
   Stack1.Push(value)
   If StrAt(value,1) = "I" Then
        ShowKeyTree(Value)
        st = StrReplace(value,"I","F")
        If search(st) = 1 Then  ShowKeyTree(st)
        st = StrReplace(value,"I","O")
        If search(st) = 1 Then  ShowKeyTree(st)
        st = StrReplace(value,"I","S")
        If search(st) = 1 Then  ShowKeyTree(st)
   Else
     ShowKeyTree(Value)
   End If
End Sub

Sub search(s)
For i = 0 To combobox1.Count -1
  If combobox1.Item(i) = s Then Return 1
Next
Return 0
End Sub
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is better to search in GEDParser.htKeys. Finding a key in a Hashtable is much faster than going over all items (O(1) compared to O(n)):
B4X:
st = StrReplace(value,"I","F")
If GEDParser.htKeys.Contains(st) Then  ShowKeyTree(st)
st = StrReplace(value,"I","O")
If GEDParser.htKeys.Contains(st) Then  ShowKeyTree(st)
st = StrReplace(value,"I","S")
If GEDParser.htKeys.Contains(st) Then  ShowKeyTree(st)
 

derez

Expert
Licensed User
Longtime User
Thank you.

Finding the father,mother and spouse names requires to look at NAME of their trees, which are found under FAMC (father and mother) and FAMS (spouse), of the person's tree.
Is there a way to find it also through the hash table without the need to actually build these trees ?

A INDI and FAM trees as an example:
0 @I185@ INDI
1 NAME Yitzhak Meir /Hacohen Shwartz/
2 GIVN Yitzhak
2 SURN Hacohen Shwartz
2 NICK Meir
1 SEX M
1 BIRT
2 DATE 3.5.1866
1 DEAT
2 DATE 29.4.1936
1 FAMC @F170@
1 FAMS @F185@
1 ADDR
2 CONT Hungaria Dragmirsht
2 _NAME n/a
2 CTRY Hungaria
2 CITY Dragmirsht
0 @F185@ FAM
1 HUSB @I185@
1 WIFE @I1217@
1 MARR
2 DATE 1882
1 CHIL @I602@
1 CHIL @I594@
1 CHIL @I593@
1 CHIL @I588@
1 CHIL @I581@
1 CHIL @I579@
1 CHIL @I551@
1 CHIL @I549@

This is in the case of male person, the FAMS is usually with the same number as the INDI, but for a female, it will be a different number - that of her husband.

The reference in FAMC is to F170 :
0 @F170@ FAM
1 HUSB @I170@
1 WIFE @I169@
1 MARR
2 DATE 7.6.1865
1 CHIL @I1232@
1 CHIL @I617@
1 CHIL @I203@
1 CHIL @I201@
1 CHIL @I199@
1 CHIL @I196@
1 CHIL @I194@
1 CHIL @I192@
1 CHIL @I190@
1 CHIL @I188@
1 CHIL @I186@
1 CHIL @I185@

So the Father name is in I170 and the mother name in I169.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
You could search for the interesting items in the person tree (not in the TreeView control).
If the interesting items are always first level items then it is pretty simple:
B4X:
Sub HandleINDI (key)
    record = GEDParser.htKeys.Item(key)
    item = GEDParser.Records(record).FirstSon
    Do While item <> ""
        Select GEDParser.Records(item).Tag
            Case "FAMC", "FAMS":
                Msgbox(GEDParser.Records(item).Value)
            'Case "AAAA":
        End Select
        item = GEDParser.Records(item).NextSibling
    Loop
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The following code can be added to GEDParser.bas to allow searching for a specific tag:
B4X:
Public Sub FindRecord (root, tag)
    If Records(root).Tag = tag Then Return root
    son = Records(root).FirstSon
    If son <> "" Then
        Return FindRecordHelper (son, tag)
    End If
    Return -1
End Sub
Sub FindRecordHelper (root, tag)
    If Records(root).Tag = tag Then Return root
    son = Records(root).FirstSon
    If son <> "" Then
        res = FindRecordHelper (son, tag)
        If res >= 0 Then Return res
    End If
    nextSibling = Records(root).NextSibling
    If nextSibling <> "" Then
        Return FindRecordHelper (nextSibling, tag)
    End If
    Return -1
End Sub
It will return the first record which belongs to the given key with the specified tag (not limited to level 1 tags).
Example of using it (from the main module):
B4X:
    record = GEDParser.htKeys.Item("@I1@")
    fams = GEDParser.FindRecord(record, "CAUS")
    If fams > -1 Then
        Msgbox(GEDParser.Records(fams).Value, fams)
    End If
 

derez

Expert
Licensed User
Longtime User
Thanks Erel.

I was going in that direction (searching the records ) but not yet with this efficiency.

I'm sure I can handle it from here on.:)
 

derez

Expert
Licensed User
Longtime User
GEDCOM file Viewer

I attach the Gedcom_viewer which I managed to build using the tools of Erel - the parser and the search tools.

I modified the find tool slightly - I added the capability to find more than one item (by arraylist).

The main part of the program is utilizing these tools to display most of the important and basic information of each person in a better way than the file itself.

For a specific use it must be tailored, to define the data items that you want to be displayed as well, but it can be done easily by modifying the existing definitions in the code.

I hope it will be of use to someone, keeping in mind that it is not fully debugged.
 

Attachments

  • GED_View.sbp
    13.8 KB · Views: 305

derez

Expert
Licensed User
Longtime User
People who deal with family trees are used to searching, they will find it...
 

derez

Expert
Licensed User
Longtime User
I add another version for the same application, in which the searches are implemented only through the Gedparser records, not in the tree nodes.

I really don't know which version works better, so the two options are valid.

The same disclaimer : it is not fully debugged and it does not show all the data in the Gedcom file - you have to tailor it to your needs.
 

mjcoon

Well-Known Member
Licensed User
I add another version for the same application, in which the searches are implemented only through the Gedparser records, not in the tree nodes.

I really don't know which version works better, so the two options are valid.

The same disclaimer : it is not fully debugged and it does not show all the data in the Gedcom file - you have to tailor it to your needs.

Hi Derez, are you still looking at this forum? Where is the new version? I see no edit to the previous one...

I have downloaded a version with two menu items (in Hebrew?) which do not link to code.

Cheers, Mike (who has family tree GEDCOM files I would like to progress; the family keeps growing!)
 

derez

Expert
Licensed User
Longtime User
are you still looking at this forum?
Yes, but mainly at the android part of it.

I found this version 2 of the GED_View program and I attach it here, but I don't remember much of it to explain. anyway - neither this not version1 are with Hebrew menu !
(version 1 is few posts above ).

If you need further assistance - I'll dive into it...
 

Attachments

  • GED_View2.sbp
    14.1 KB · Views: 256
Top