gedcom

package module
v0.0.0-...-026a8b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2018 License: Unlicense Imports: 7 Imported by: 1

README

gedcom

Go package to parse GEDCOM files.

Usage

The package provides a Decoder with a single Decode method that returns a Gedcom struct. Use the NewDecoder method to create a new decoder.

This example shows how to parse a GEDCOM file and list all the individuals. In this example the entire input file is read into memory, but the decoder is streaming so it should be able to deal with very large files: just pass an appropriate Reader.

package main

import (
	"bytes"
	"github.com/iand/gedcom"
	"io/ioutil"
)

func main() {
	data, _ := ioutil.ReadFile("testdata/kennedy.ged")

	d := gedcom.NewDecoder(bytes.NewReader(data))

	g, _ := d.Decode()

	for _, rec := range g.Individual {
		if len(rec.Name) > 0 {
			println(rec.Name[0].Name)
		}			
	}
}

The structures produced by the Decoder are in types.go and correspond roughly 1:1 to the structures in the GEDCOM specification.

This package does not implement the entire GEDCOM specification, I'm still working on it. It's about 80% complete which is enough for about 99% of GEDCOM files. It has not been extensively tested with non-ASCII character sets nor with pathological cases such as the [http://www.geditcom.com/gedcom.html](GEDCOM 5.5 Torture Test Files).

Installation

Simply run

go get github.com/iand/gedcom

Documentation is at http://godoc.org/github.com/iand/gedcom

Authors

Contributors

Contributing

  • Do submit your changes as a pull request
  • Do your best to adhere to the existing coding conventions and idioms.
  • Do run go fmt on the code before committing
  • Do feel free to add yourself to the CREDITS file and the corresponding Contributors list in the the README.md. Alphabetical order applies.
  • Don't touch the AUTHORS file. An existing author will add you if your contributions are significant enough.
  • Do note that in order for any non-trivial changes to be merged (as a rule of thumb, additions larger than about 15 lines of code), an explicit Public Domain Dedication needs to be on record from you. Please include a copy of the statement found in the WAIVER file with your pull request

License

This is free and unencumbered software released into the public domain. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressRecord

type AddressRecord struct {
	Full       string
	Line1      string
	Line2      string
	City       string
	State      string
	PostalCode string
	Country    string
	Phone      string
}

AddressRecord describes and address.

type ChangedRecord

type ChangedRecord struct {
	Stamp *TimestampRecord
	Note  []*NoteRecord
}

ChangedRecord describes a document change.

type ChildRecord

type ChildRecord struct {
	FatherRelation string
	MotherRelation string
	Person         *IndividualRecord
}

ChildRecord describes a child within a family.

type CitationRecord

type CitationRecord struct {
	Source  *SourceRecord
	Page    string
	Data    DataRecord
	Quality string
	Object  []*ObjectRecord
	Note    []*NoteRecord
}

CitationRecord links another record and a source.

type CorpRecord

type CorpRecord struct {
	Name    string
	Address *AddressRecord
	Phone   []string
}

CorpRecord describes the corporation producing the software that generated the Gedcom.

type DataRecord

type DataRecord struct {
	Date string
	Text []string
}

DataRecord ...

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

A Decoder reads and decodes GEDCOM objects from an input stream.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new decoder that reads from r.

func (*Decoder) Decode

func (d *Decoder) Decode() (*Gedcom, error)

Decode reads the next GEDCOM-encoded value from its input and stores it in the value pointed to by v.

func (*Decoder) SetUnrecTagFunc

func (d *Decoder) SetUnrecTagFunc(f func(int, string, string, string))

SetUnrecTagFunc sets the callback function for unrecognized tags.

type EncodingRecord

type EncodingRecord struct {
	Name    string
	Version string
}

EncodingRecord describes a character encoding.

type EventRecord

type EventRecord struct {
	Tag        string
	Value      string
	Type       string
	Date       string
	SortDate   time.Time
	Place      PlaceRecord
	Address    AddressRecord
	Age        string
	Agency     string
	Citation   []*CitationRecord
	Object     []*ObjectRecord
	Note       []*NoteRecord
	Cause      []*NoteRecord
	Parents    []*FamilyLinkRecord
	SpouseInfo []*SpouseInfoRecord
}

EventRecord describes a life event.

type FamilyLinkRecord

type FamilyLinkRecord struct {
	Family    *FamilyRecord
	Pedigree  string
	AdoptedBy string
	Note      []*NoteRecord
}

FamilyLinkRecord ...

type FamilyRecord

type FamilyRecord struct {
	Xref             string
	Husband          *IndividualRecord
	Wife             *IndividualRecord
	NumberOfChildren *EventRecord
	Changed          *ChangedRecord
	Child            []*ChildRecord
	Event            []*EventRecord
	Citation         []*CitationRecord
	Object           []*ObjectRecord
	Note             []*NoteRecord
}

FamilyRecord describes a family unit.

type FileRecord

type FileRecord struct {
	Name        string
	Title       string
	Form        string
	Description *NoteRecord
}

FileRecord ...

type Gedcom

type Gedcom struct {
	Header     *HeaderRecord
	Submission *SubmissionRecord
	Submitter  []*SubmitterRecord
	Family     []*FamilyRecord
	Individual []*IndividualRecord
	Object     []*ObjectRecord
	Repository []*RepositoryRecord
	Source     []*SourceRecord
	Note       []*NoteRecord
	Trailer    *Trailer
}

Gedcom is the top level structure.

type HeaderDataRecord

type HeaderDataRecord struct {
	Name      string
	Date      string
	Copyright string
}

HeaderDataRecord ...

type HeaderInfoRecord

type HeaderInfoRecord struct {
	Version string
	Form    string
}

HeaderInfoRecord contains information about the Gedcom version

type HeaderRecord

type HeaderRecord struct {
	Date        string
	Destination string
	File        string
	Copyright   string
	Language    string
	Timestamp   *TimestampRecord
	Encoding    *EncodingRecord
	Source      *HeaderSourceRecord
	Submitter   *SubmitterRecord
	Submission  *SubmissionRecord
	Info        *HeaderInfoRecord
	Note        *NoteRecord
}

HeaderRecord is the heading of the Gedcom file.

type HeaderSourceRecord

type HeaderSourceRecord struct {
	Source      string
	Version     string
	Name        string
	Form        string
	Corporation *CorpRecord
	Data        *HeaderDataRecord
}

HeaderSourceRecord ...

type IndividualRecord

type IndividualRecord struct {
	Xref      string
	Sex       string
	Changed   *ChangedRecord
	Photo     *ObjectRecord
	Name      []*NameRecord
	Event     []*EventRecord
	Attribute []*EventRecord
	Parents   []*FamilyLinkRecord
	Family    []*FamilyLinkRecord
	Citation  []*CitationRecord
	Object    []*ObjectRecord
	Note      []*NoteRecord
}

IndividualRecord describes a single person.

type NameRecord

type NameRecord struct {
	Name     string
	Prefix   string
	Suffix   string
	Citation []*CitationRecord
	Note     []*NoteRecord
}

NameRecord describes a person's name.

type NoteRecord

type NoteRecord struct {
	Xref     string
	Note     string
	Citation []*CitationRecord
}

NoteRecord describes a text note.

type ObjectRecord

type ObjectRecord struct {
	Xref string
	File *FileRecord
	Note []*NoteRecord
}

ObjectRecord describes a source object.

type PlaceRecord

type PlaceRecord struct {
	Name      string
	Latitude  string
	Longitude string
	Citation  []*CitationRecord
	Note      []*NoteRecord
}

PlaceRecord describes a location.

type RepositoryRecord

type RepositoryRecord struct {
	Xref string
}

RepositoryRecord is currently not implemented.

type SourceDataRecord

type SourceDataRecord struct {
	Agency string
	Event  []*EventRecord
	Note   []*NoteRecord
}

SourceDataRecord describes events pertaining to this source

type SourceRecord

type SourceRecord struct {
	Xref        string
	Author      string
	Title       string
	Abbr        string
	Publication string
	Type        string
	Text        string
	MediaType   string
	Periodical  string
	Volume      string
	Page        []string
	Film        []string
	File        []string
	FileNumber  []string
	Place       []string
	Date        []string
	DateViewed  []string
	URL         []string
	DocLocation []string
	Repository  []string
	Submitter   []string
	Changed     *ChangedRecord
	EventData   *SourceDataRecord
	Note        []*NoteRecord
	Object      []*ObjectRecord
}

SourceRecord describes a single source document.

func (*SourceRecord) GetReferenceString

func (s *SourceRecord) GetReferenceString() string

getReferenceString returns a reference to the source.

type SpouseInfoRecord

type SpouseInfoRecord struct {
	Spouse string
	Age    string
}

SpouseInfoRecord describes information about a spouse referenced in a family event.

type SubmissionRecord

type SubmissionRecord struct {
	Xref        string
	FamilyFile  string
	TempleCode  string
	Ancestors   string
	Descendants string
	Ordinance   string
	Submitter   *SubmitterRecord
}

SubmissionRecord ...

type SubmitterRecord

type SubmitterRecord struct {
	Xref     string
	Name     string
	Language string
	Phone    []string
	Address  *AddressRecord
	Changed  *ChangedRecord
}

SubmitterRecord describes a submitter.

type TimestampRecord

type TimestampRecord struct {
	Date string
	Time string
}

TimestampRecord describes a timestamp.

type Trailer

type Trailer struct {
}

The Trailer doesn't do anything but mark the end of the file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL