Giter Club home page Giter Club logo

gedcom's Introduction

gedcom

A small, simple parser for GEDCOM 5.5.1.

API Documentation

Installation

The gedcom package can be added as a dependency to use in your code, or if you'd like to just use the CLI, install it globallly:

npm install -g gedcom

CLI

Usage
$ parse-gedcom <input>
	Options
	  --type, -s   Output type (json, d3.json, dot)
	Examples
	  $ gedcom input.ged output.json

Caveats

  • The GEDCOM specification allows use of an ANSEL character encoding - a nearly-unknown predecessor to UTF-8. This parser doesn't currently handle ANSEL encoding, so it may behave oddly with files in ANSEL. However, it appears that most programs that export GEDCOM default to or at least support UTF-8, which is recommended instead.
  • The GEDCOM standard is ubiquitous and practical, but has embedded cultural biases. This parser allows "non-standard" input in places where GEDCOM is bigoted, like the SEX_VALUE field.

gedcom's People

Contributors

fetimo avatar greenkeeper[bot] avatar markario avatar tmcw 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  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  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  avatar  avatar

gedcom's Issues

Tried on a GenoPro .ged file and got an error

The source of the error was that a link node was generated with no target attribute, I fixed locally by filtering links by checking that both source and target were defined but am not sending a PR since I didn't figure out the underlying issue.

Here's a screenshot of the rendered graph which I thought was pretty cool.

By way of explanation for why I've now popped up a second time in your projects, I'm a huge fan of JavaScript mapping & also of genealogy and saw this repo in my GitHub timeline. Also, madprime is my coworker and I noticed you use the regex from her repo--super small world!

An in-range update of browserify is breaking the build 🚨

Version 15.1.0 of browserify was just published.

Branch Build failing 🚨
Dependency browserify
Current Version 15.0.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

browserify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v15.1.0
  • restore support for node < 4.0 until we can decide on a support schedule
Commits

The new version differs by 8 commits.

  • 6dbd142 15.1.0
  • 00f226b changelog
  • c668b99 Merge pull request #1794 from ljharb/restore_old_node
  • a522c43 Set engines back to 0.8 (reverts #1793)
  • 2ab8502 [Tests] skip template literal tests unless supported
  • 7a6116c [Tests] skip generator tests in nodes that don’t support generators
  • ea84e09 [Deps] upgrade module-deps
  • 1d5ebb6 [Tests] start testing in older nodes again

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of tape is breaking the build 🚨

Version 4.9.0 of tape was just published.

Branch Build failing 🚨
Dependency tape
Current Version 4.8.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

tape is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 27 commits.

  • ea6d91e v4.9.0
  • 6867840 [Deps] update object-inspect, resolve
  • 4919e40 [Tests] on node v9; use nvm install-latest-npm
  • f26375c Merge pull request #420 from inadarei/global-depth-env-var
  • 17276d7 [New] use process.env.NODE_TAPE_OBJECT_PRINT_DEPTH for the default object print depth.
  • 0e870c6 Merge pull request #408 from johnhenry/feature/on-failure
  • 00aa133 Add "onFinish" listener to test harness.
  • 0e68b2d [Dev Deps] update js-yaml
  • 10b7dcd [Fix] fix stack where actual is falsy
  • 13173a5 Merge pull request #402 from nhamer/stack_strip
  • f90e487 normalize path separators in stacks
  • b66f8f8 [Deps] update function-bind
  • cc69501 Merge pull request #387 from fongandrew/master
  • bf5a750 Handle spaces in path name for setting file, line no
  • 3c2087a Test name with spaces

There are 27 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Invalid graph links generated by .d3ize()

I am trying out this library and imported the sample gedcom file found on:
http://heiner-eichmann.de/gedcom/allged.htm
The essential contents of this file are 8 individuals and 4 families, giving 12 nodes and 11 expected edges in the graph.

The parser gets through it all and makes seemingly valid JSON, but when I pass that into .d3ize(), there is one bad link among the 12 links returned:

links: [ { source: 8, target: 0 },
  { source: 8, target: 1 },
  { source: 8, target: 2 },
  { source: 8, target: 3 },
  { source: 8, target: undefined }, <-- invalid
  { source: 9, target: 4 },
  { source: 9, target: 0 },
  { source: 10, target: 5 },
  { source: 10, target: 0 },
  { source: 11, target: 0 },
  { source: 11, target: 7 },
  { source: 11, target: 6 } ]

I haven't found out what caused it yet, and for now I'm going to work around the error by testing for undefined values before I plug the JSON into dagre-d3 for graphing.

Trailing blanks are stripped from notes

In NOTE records CONC and CONT lines may or may not have a trailing blank character depending on the context of the note. This is getting stripped off and it messes up the results when reconstructing the NOTE message. IE: the trailing blank if it exists is significant and should not be removed.

I changed line 60 in index.js to say:

data: match[4].trimLeft(),

And this fixes the problem and does not appear to break anything else.

Fix docs link

Pretty easy one, right now docs/README exists and docs/modules doesn't. Just fix the link in README.md

An in-range update of d3 is breaking the build 🚨

Version 4.13.0 of d3 was just published.

Branch Build failing 🚨
Dependency d3
Current Version 4.12.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

d3 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Syntax error near unexpected token `('

When I try to run the following:

parse-gedcom test.ged test.json

I get the following:

/usr/local/bin/parse-gedcom: line 1: syntax error near unexpected token ('
/usr/local/bin/parse-gedcom: line 1: var e=require("fs"),t=require("path"),r=require("meow"),n=require("get-stdin"),E=require("unist-util-visit-parents"),a=require("unist-util-remove"),A=require("graphlib-dot"),i=require("graphlib");function I(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=I(e),N=I(t),R=I(r),u=I(n),T=I(E),l=I(a),S=I(A);function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function C(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?O(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}var f=new RegExp("^([0-9]*)"),d=new RegExp("(\\s+)"),c=new RegExp("^(["+d+"])"),s=new RegExp("^@([A-ZÀ-ÿa-z_0-9])([A-ZÀ-ÿa-z_0-9"+d+"#])*@"),v=new RegExp("^(_?[A-ZÀ-ÿa-z_0-9]+)"),M=new RegExp(/^(.*)/);function D(e){function t(t,r){var n=e.match(t);if(!n)throw new Error(r);return e=e.substring(n[0].length),n[1]}e=e.trimStart();var r=void 0,n=t(f,"Expected level");if(n.length>2||2===n.length&&"0"===n[0])throw new Error("Invalid level: "+n);var E=parseInt(n);t(c,"Expected delimiter after level");var a=e.match(s);a&&(r=a[0],e=e.substring(a[0].length),t(c,"Expected delimiter after pointer"));var A={level:E,tag:t(v,"Expected tag")};r&&(A.xref_id=r);var i=e.match(c);if(i){var I=(e=e.substring(i[0].length)).match(s),o=e.match(M);I?A.pointer=I[0]:o&&(A.value=o[1])}return A}var L={ABBR:"ABBREVIATION",ADDR:"ADDRESS",ADR1:"ADDRESS1",ADR2:"ADDRESS2",ADOP:"ADOPTION",AFN:"AFN",AGE:"AGE",AGNC:"AGENCY",ALIA:"ALIAS",ANCE:"ANCESTORS",ANCI:"ANCES_INTEREST",ANUL:"ANNULMENT",ASSO:"ASSOCIATES",AUTH:"AUTHOR",BAPL:"BAPTISM-LDS",BAPM:"BAPTISM",BARM:"BAR_MITZVAH",BASM:"BAS_MITZVAH",BIRT:"BIRTH",BLES:"BLESSING",BURI:"BURIAL",CALN:"CALL_NUMBER",CAST:"CASTE",CAUS:"CAUSE",CENS:"CENSUS",CHAN:"CHANGE",CHAR:"CHARACTER",CHIL:"CHILD",CHR:"CHRISTENING",CHRA:"ADULT_CHRISTENING",CITY:"CITY",CONC:"CONCATENATION",CONF:"CONFIRMATION",CONL:"CONFIRMATION_LDS",CONT:"CONTINUED",COPR:"COPYRIGHT",CORP:"CORPORATE",CREM:"CREMATION",CTRY:"COUNTRY",DATA:"DATA",DATE:"DATE",DEAT:"DEATH",DESC:"DESCENDANTS",DESI:"DESCENDANT_INT",DEST:"DESTINATION",DIV:"DIVORCE",DIVF:"DIVORCE_FILED",DSCR:"PHY_DESCRIPTION",EDUC:"EDUCATION",EMAI:"EMAIL",EMIG:"EMIGRATION",ENDL:"ENDOWMENT",ENGA:"ENGAGEMENT",EVEN:"EVENT",FACT:"FACT",FAM:"FAMILY",FAMC:"FAMILY_CHILD",FAMF:"FAMILY_FILE",FAMS:"FAMILY_SPOUSE",FAX:"FACIMILIE",FCOM:"FIRST_COMMUNICATION",FILE:"FILE",FORM:"FORMAT",FONE:"PHONETIC",GEDC:"GEDCOM",GIVN:"GIVEN_NAME",GRAD:"GRADUATION",HEAD:"HEADER",HUSB:"HUSBAND",IDNO:"IDENT_NUMVER",IMMI:"IMMIGRATION",INDI:"INDIVIDUAL",LANG:"LANGUAGE",LATI:"LATITUDE",LONG:"LONGITUDE",MAP:"MAP",MARB:"MARRIAGE_BANN",MARC:"MARRIAGE_CONTRACT",MARL:"MARRIAGE_LICENSE",MARR:"MARRIAGE",MARS:"MARRIAGE_SETTLEMENT",MEDI:"MEDIA",NAME:"NAME",NATI:"NATIONALITY",NATU:"NATURALIZATION",NCHI:"CHILDREN_COUNT",NICK:"NICKNAME",NMR:"MARRIAGE_COUNT",NOTE:"NOTE",NPFX:"NAME_PREFIX",NSFX:"NAME_SUFFIX",OBJE:"OBJECT",OCCU:"OCCUPATION",ORDI:"ORDINANCE",ORDN:"ORDINATION",PAGE:"PAGE",PEDI:"PEDIGREE",PHON:"PHONE",PLAC:"PLACE",POST:"POSTAL_CODE",PROB:"PROBATE",PROP:"PROPERTY",PUBL:"PUBLICATION",QUAY:"QUALITY_OF_DATA",REFN:"REFERENCE",RELA:"RELATIONSHIP",RELI:"RELIGION",REPO:"REPOSITORY",RESI:"RESIDENCE",RESN:"RESTRICTION",RETI:"RETIREMENT",RFN:"REC_FILE_NUMBER",RIN:"REC_ID_NUMBER",ROLE:"ROLE",ROMN:"ROMANIZED",SEX:"SEX",SLGC:"SEALING_CHILD",SLGS:"SEALING_SPOUCE",SOUR:"SOURCE",SPFX:"SURN_PREFIX",SSN:"SURN_PREFIX",STAE:"STATE",STAT:"STATUS",SUBM:"SUBMITTER",SUBN:"SUBMISSION",SURN:"SURNAME",TEMP:"TEMPLE",TEXT:"TEXT",TIME:"TIME",TITL:"TITLE",TRLR:"TRAILER",TYPE:"TYPE",VERS:"VERSION",WIFE:"WIFE",WILL:"WILL",WWW:"WEB"},p=new RegExp("(\\r|\\n|\\r\\n|\\n\\r)","g");function U(e){var t=e.tag,r=e.xref_id,n=e.pointer,E={type:t,data:{formal_name:L[t]},value:e.value,children:[]};return r&&(E.data.xref_id=r),n&&(E.data.pointer=n),t.startsWith("_")&&(E.data.custom_tag=!0),E}function h(e,t){var r=e.tag,n=e.value;if("CONC"!==r&&"CONT"!==r)return!1;if(e.pointer)throw new Error("Cannot concatenate a pointer");return t.value||(t.value=""),"CONT"===r&&(t.value+="\n"),n&&(t.value+=n),!0}function P(e,t,r){e[t]?e["+"+t]=(e["+"+t]||[]).concat(r):e[t]=r}function _(e){var t=function(e,t){void 0===t&&(t=["TRLR","SUBM","SUBN","HEAD","NOTE","SOUR"]),l.default(e,t);for(var r,n=function(){var e=r.value;e.data||(e.data={}),T.default(e,function(t,r){var n,E=r.slice(1).concat(t).map(function(e){var t;return(null==(t=e.data)?void 0:t.formal_name)||e.type}).join("/");t.value?P(e.data,E,t.value):null!=(n=t.data)&&n.pointer&&P(e.data,"@"+E,t.data.pointer)}),e.children=[]},E=C(e.children);!(r=E()).done;)n();return e}(e).children,r=new Set(t.map(function(e){var t;return null==(t=e.data)?void 0:t.xref_id}).filter(Boolean)),n=[],E=new Map;return t.forEach(function(e){e.data&&Object.entries(e.data).filter(function(e){return e[0].startsWith("@")}).forEach(function(t){var a,A,i=t[0],I=t[1];if(!r.has(I))throw new Error("Undefined reference: "+I);if(null==(a=e.data)||!a.xref_id)throw new Error("Link from node with no xref id");var o=null==(A=e.data)?void 0:A.xref_id,N=I,R={source:o,target:N,value:i};n.push(R);var u=[o,N].sort().join("/");E.has(u)?E.get(u).push(R):E.set(u,[R])})}),function(e,t){for(var r,n=[["@HUSBAND","@FAMILY_SPOUSE"],["@WIFE","@FAMILY_SPOUSE"],["@FAMILY_CHILD","@CHILD"]],E=function(){var e=r.value[1];n.forEach(function(r){var n=r.map(function(t){return e.find(function(e){return e.value==t})}),E=n[0];E&&n[1]&&t.splice(t.indexOf(E),1)})},a=C(e);!(r=a()).done;)E()}(E,n),{nodes:t,links:n}}var g=R.default("\n\tUsage\n\t $ parse-gedcom <input>\n\tOptions\n\t --type, -s Output type (json, d3.json, dot)\n\tExamples\n\t $ parse-gedcom input.ged output.json\n",{flags:{type:{type:"string",alias:"t"}}}),F={".json":"json",".d3.json":"force",".dot":"dot"};!function(){try{var e=function(e){var t=function(e){for(var t,r={type:"root",children:[]},n=[],E=0,a=C(e.split(p).filter(function(e){return e.trim()}));!(t=a()).done;){var A=D(t.value);if(!h(A,n[n.length-1])){var i=U(A),I=A.level;if(0==I)r.children.push(i),n=[i];else{if(!(E==I-1||I<=E))throw new Error("Illegal nesting: transition from "+E+" to "+I);for(var o=0;o<=E-I;o++)n.pop();n[n.length-1].children.push(i),n.push(i)}E=I}}return r}(e),r="json";if(g.flags.type)r=g.flags.type;else if(n){var E=N.default.extname(n);E in F&&(r=F[E])}var a="";switch(r){case"json":return void(a=JSON.stringify(t,null,2));case"d3.json":return void(a=JSON.stringify(_(t),null,2));case"dot":return void(a=S.default.write(function(e){for(var t,r=_(e),n=r.nodes,E=r.links,a=new i.Graph,A=C(n);!(t=A()).done;){var I,o=t.value,N=(o.data||{}).NAME;a.setNode(null==(I=o.data)?void 0:I.xref_id,{label:N?N.replace(/^@/,""):o.type})}for(var R,u=C(E);!(R=u()).done;){var T=R.value;a.setEdge(T.source,T.target,{label:T.value})}return a}(t)))}n?o.default.writeFileSync(n,a,"utf8"):process.stdout.write(a)},t=g.input,r=t[0],n=t[1];r?e(o.default.readFileSync(r,"utf8")):Promise.resolve(u.default()).then(e)}catch(e){Promise.reject(e)}}();'

I've run this with both a very complex/long .ged file and a very simple .ged file. Have also attempted to output to .dot and .json file. Same error results regardless.

nothing silently seems to happen when run from the CLI

agill@adar81:~/Documents/family_tree/GRAMPS/temp$ which gedcom
/usr/local/bin/gedcom
agill@adar81:~/Documents/family_tree/GRAMPS/temp$ gedcom
agill@adar81:~/Documents/family_tree/GRAMPS/temp$ gedcom Untitled_1.ged output.json
agill@adar81:~/Documents/family_tree/GRAMPS/temp$ ls
Untitled_1.ged
agill@adar81:~/Documents/family_tree/GRAMPS/temp$ 

The GEDCOM file to convert was created in Gramps.
I gather this isn't a support forum and I could be stepping through the code, but any help would help. TIA.

getting syntax error attempting to run it with npx on Ubuntu

I get a syntax error when I attempt to run this in an otherwise empty directory created just for trying to reproduce the error:

luke@opus95:/tmp$ mkdir gedcom
luke@opus95:/tmp$ cd gedcom/
luke@opus95:/tmp/gedcom$ npm i gedcom
npm WARN deprecated @types/[email protected]: This is a stub types definition. minimist-options provides its own type definitions, so you do not need this installed.
npm WARN saveError ENOENT: no such file or directory, open '/tmp/gedcom/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/tmp/gedcom/package.json'
npm WARN gedcom No description
npm WARN gedcom No repository field.
npm WARN gedcom No README data
npm WARN gedcom No license field.

+ [email protected]
added 211 packages from 185 contributors and audited 211 packages in 19.273s

24 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

luke@opus95:/tmp/gedcom$ npx parse-gedcom -s json gramps.ged gramps.json
npx: installed 211 in 47.761s
/home/schierer/luke/.npm/_npx/180150/bin/parse-gedcom: 1: Syntax error: "(" unexpected
luke@opus95:/tmp/gedcom$ npm --version
6.14.15
luke@opus95:/tmp/gedcom$ 

Include `pos` data with the AST

The tokenizer I've written is "one token per line", so it's not quite a real tokenizer. It would be useful, if we want to emit nice errors, to actually record locations of things. That would help integrating with the unified ecosystem, like vfile, for reporters.

Serializer

@tmcw do you know any serializers to bring JSON back to the *.ged format? Will it make sense to build it into this package?

Name parser

Names in GEDCOM look like John /Smith/. We should include a parser to make it easier to show a chart with the last name not in slashes.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.