gedcom

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: Unlicense Imports: 4 Imported by: 2

README

gedcom

Go package to parse GEDCOM files.

Build Status

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 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

Overview

Package gedcom provides a functions to parse GEDCOM files.

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
}

type CitationRecord

type CitationRecord struct {
	Source *SourceRecord
	Page   string
	Data   DataRecord
	Quay   string
	Media  []*MediaRecord
	Note   []*NoteRecord
}

type DataRecord

type DataRecord struct {
	Date string
	Text []string
}

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 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.

type EventRecord

type EventRecord struct {
	Tag      string
	Value    string
	Type     string
	Date     string
	Place    PlaceRecord
	Address  AddressRecord
	Age      string
	Agency   string
	Cause    string
	Citation []*CitationRecord
	Media    []*MediaRecord
	Note     []*NoteRecord
}

type FamilyLinkRecord

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

type FamilyRecord

type FamilyRecord struct {
	Xref    string
	Husband *IndividualRecord
	Wife    *IndividualRecord
	Child   []*IndividualRecord
	Event   []*EventRecord
}

type Gedcom

type Gedcom struct {
	Header           *Header
	SubmissionRecord *SubmissionRecord
	Family           []*FamilyRecord
	Individual       []*IndividualRecord
	Media            []*MediaRecord
	Repository       []*RepositoryRecord
	Source           []*SourceRecord
	Submitter        []*SubmitterRecord
	Trailer          *Trailer
}
type Header struct {
	SourceSystem SystemRecord
}

type IndividualRecord

type IndividualRecord struct {
	Xref      string
	Name      []*NameRecord
	Sex       string
	Event     []*EventRecord
	Attribute []*EventRecord
	Parents   []*FamilyLinkRecord
	Family    []*FamilyLinkRecord
}

type MediaRecord

type MediaRecord struct {
}

type NameRecord

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

type NoteRecord

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

type PlaceRecord

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

type RepositoryRecord

type RepositoryRecord struct {
}

type SourceRecord

type SourceRecord struct {
	Xref  string
	Title string
	Media []*MediaRecord
	Note  []*NoteRecord
}

type SubmissionRecord

type SubmissionRecord struct {
	Xref string
}

type SubmitterRecord

type SubmitterRecord struct {
}

type SystemRecord

type SystemRecord struct {
	Id              string
	Version         string
	ProductName     string
	BusinessName    string
	Address         AddressRecord
	SourceName      string
	SourceDate      string
	SourceCopyright string
}

type Trailer

type Trailer struct {
}

Jump to

Keyboard shortcuts

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