Coder Social home page Coder Social logo

gedcompy's Introduction

gedcompy

https://travis-ci.org/rory/gedcompy.svg?branch=master https://coveralls.io/repos/rory/gedcompy/badge.png?branch=master

Python library to parse and work with GEDCOM (genealogy/family tree) files.

It's goal is to support GEDCOM v5.5 (specification here).

This is released under the GNU General Public Licence version 3 (or at your option, a later version). See the file LICENCE for more.

Example Usage

>>> import gedcom
>>> gedcomfile = gedcom.parse("myfamilytree.ged")
>>> for person in gedcomfile.individuals:
...    firstname, lastname = person.name
...    print "{0} {1} is in the file".format(firstname, lastname)

Contributing

Run all unitttests with tox.

gedcompy's People

Contributors

biogeek avatar chrrrisw avatar ropez avatar vtbassmatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gedcompy's Issues

Exception on individuals with just first name

I have export from Geni.com, where for some people I know only first name.

Your code was falling on command preferred_name.value.split("/") in @Property def name(self). Hence I slightly modified code to this. Consider putting this or something similar to your code. I dont have experiencies with GitHub, so I dont know if I can somehow join to the team and fix or suggest fixes.

Updated code:

    @property
    def name(self):
        """
        Return this person's name.

        :returns: (firstname, lastname)
        """
        name_tag = self['NAME']

        if isinstance(name_tag, list):
            # We have more than one name, get the preferred name
            # Don't assume it's the first
            for name in name_tag:

                if 'TYPE' not in name:
                    preferred_name = name
                    break

        else:
            # We've only one name
            preferred_name = name_tag

        if preferred_name.value in ('', None):
            first = preferred_name['GIVN'].value
            last = preferred_name['SURN'].value
        else:
            vals = preferred_name.value.split("/")
            first, last, dud = "", "", ""
            first = vals[0].strip() # This is the fix I was writing about
            if len(vals) > 1:
                last = vals[1].strip()

        return first, last

dunder-getitem and get_list essentially the same

Hi,
my changes to resolve the multiple names issue has essentially made dunder-getitem() and get_list() the same, except that dunder-getitem() returns either a list or a single object depending on the number of child elements. This made the client code in name() more complex as I had to check if a list or Element was returned.
The name() method could use get_list() instead and if we were to add, say, a spouses() property, this would use the same mechanism. Or we could remove the get_list() method and always return a list from the dunder-getitem() method.
This issue is mainly at the discussion stage - what do you see as the way forward?
Cheers,
Chris.

UnboundLocalError: local variable 'first' referenced before assignment

Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1536, in call
return self.func(*args)
File "Launcher.py", line 1426, in gedcom_step1
self.get_data_gedcom()
File "Launcher.py", line 1044, in get_data_gedcom
name = " ".join(ind.name)
File "C:\Python27\lib\site-packages\gedcom_init_.py", line 431, in name
return first, last
UnboundLocalError: local variable 'first' referenced before assignment

It's because sometime surname have symbol like "/" to seperate different type of name

it's possible to split at the first "/" ? like:

        vals = preferred_name.value.split("/")

to:

        vals = preferred_name.value.split("/",1)

It's can work ?

Because some people add some special symbol into their Familly tree software like "SMIT/SMITH" in the surname. Now poeple like to add some more information to explain the different kind of writing a surname can have like :

Lefeivre, Lefelvre, Lefesvre, Lefeubvre, Lefeuve, Lefeuvre, Lefève, Lefever, Lefevere, Lefèvres, Lefebvre
or with slash
Lefeivre / Lefelvre / Lefesvre / Lefeubvre / Lefeuve / Lefeuvre / Lefève / Lefever / Lefevere / Lefèvres / Lefebvre

or regex-like to avoid the writting of all the surname form:

LEFE(I-L-S-U)(B)V(R)E(R)(E)

I use your library in my application, it's can be usefull i I can push out the surnmae and the firstname individually than to call the individu.name method

Thanks

Yoan
https://peregrination.jimdo.com/
https://github.com/Tuisto59/Peregrination

NotImplementedError when xref_id comes before tag

Ancestry.com produces Gedcoms with line like this:

0 @S-460522339@ SOUR
0 @R-995799905@ REPO

From my understanding of the standard, this is valid. However, gedcompy raises NotImplementedError when it encounters lines like this (that is, when the xref comes before the tag).

Add support for Gedcom files starting with BOM

Sites like geni.com let you export Gedcom files that start with a Byte Order Mark (BOM).

Currently the regex fails for such files and you get a NotImplementedError.

See this detailed article for more about GEDCOM & the Unicode Byte Order Mark.

I'm currently toying with a solution like described here to remove the BOM and encode/decode the string, but I still get strange characters in the output.

NotImplementedError

I just ran the sample code against my gedcom file (exported from Ancestry) and I get the following:

Traceback (most recent call last):
File "./ingest.py", line 4, in
gedcomfile = gedcom.parse("myfamilytree.ged")
File "build/bdist.macosx-10.12-intel/egg/gedcom/init.py", line 760, in parse
File "build/bdist.macosx-10.12-intel/egg/gedcom/init.py", line 725, in parse_filename
File "build/bdist.macosx-10.12-intel/egg/gedcom/init.py", line 778, in __parse
NotImplementedError: Born in Milton, he was a son of Vera (Wolfe) Coombs and the late Joseph Coombs.

If willing to work on this issue then I am willing to share my gedcom file privately via email.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.