GEDCOM Parser - m0smith/topoged GitHub Wiki

GEDCOM Parser

Parses a GEDCOM file into a lazy sequence of GedcomRecord with the following elements:

  • :tag - the tag from the gedcom line, converted to a keyword :INDI, :HEAD, :FAM
  • :value - the rest of the gedcom line after the tag
  • :attrs - GedcomAttributes the attributes of this gedcom line as a map with entries including:
    • :level - the level number of the gedcom record
    • :representation - the original source for the gedcom line
    • :line-number - the line number of the gedcom line in the original sequence
  • :content - vector of nested GedcomRecord instance with this same structure representing the subordinate gedcom lines.

CONT and CONC records

Gedcom has support for long entries with CONT and CONC records. The value of these records will be added to the :value of the previous record. CONT will also have a newline added before the value.

##Example Calling gedcom-seq on a file sample.ged with this stanza:

sample.ged

0 @FATHER@ INDI
1 NAME /Father/
1 SEX M
1 BIRT
2 PLAC birth place
2 DATE 1 JAN 1899
1 DEAT
2 PLAC death place
2 DATE 31 DEC 1990
1 FAMS @FAMILY@

Calling:

(gedcom-seq "sample.ged")

Result:

{:tag :INDI,
 :value "@FATHER@",
 :attrs
 {:level "0", :line-number 12, :representation "0 @FATHER@ INDI"},
 :content
 [{:tag :NAME,
   :value "/Father/",
   :attrs
   {:level "1", :line-number 13, :representation "1 NAME /Father/"},
   :content nil}
  {:tag :SEX,
   :value "M",
   :attrs {:level "1", :line-number 14, :representation "1 SEX M"},
   :content nil}
  {:tag :BIRT,
   :value nil,
   :attrs {:level "1", :line-number 15, :representation "1 BIRT"},
   :content
   [{:tag :PLAC,
     :value "birth place",
     :attrs
     {:level "2",
      :line-number 16,
      :representation "2 PLAC birth place"},
     :content nil}
    {:tag :DATE,
     :value "1 JAN 1899",
     :attrs
     {:level "2",
      :line-number 17,
      :representation "2 DATE 1 JAN 1899"},
     :content nil}]}
  {:tag :DEAT,
   :value nil,
   :attrs {:level "1", :line-number 18, :representation "1 DEAT"},
   :content
   [{:tag :PLAC,
     :value "death place",
     :attrs
     {:level "2",
      :line-number 19,
      :representation "2 PLAC death place"},
     :content nil}
    {:tag :DATE,
     :value "31 DEC 1990",
     :attrs
     {:level "2",
      :line-number 20,
      :representation "2 DATE 31 DEC 1990"},
     :content nil}]}
  {:tag :FAMS,
   :value "@FAMILY@",
   :attrs
   {:level "1", :line-number 21, :representation "1 FAMS @FAMILY@"},
   :content nil}],
 :source-stanza-representation
 "0 @FATHER@ INDI\n1 NAME /Father/\n1 SEX M\n1 BIRT\n2 PLAC birth place\n2 DATE 1 JAN 1899\n1 DEAT\n2 PLAC death place\n2 DATE 31 DEC 1990\n1 FAMS @FAMILY@"}
⚠️ **GitHub.com Fallback** ⚠️