ged2wiki
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
ged2wiki [2007/11/18 15:26] – jims | ged2wiki [2013/01/05 18:35] – jims | ||
---|---|---|---|
Line 3: | Line 3: | ||
==== Ged2Wiki ==== | ==== Ged2Wiki ==== | ||
- | Ged2Wiki is a project to convert a GEDCOM into [[http:// | + | Ged2Wiki is a project to convert a GEDCOM into |
- | pages so that they can be added to this (or any other [[http:// | + | [[http:// |
- | site. | + | added to this (or any other |
+ | [[http:// | ||
- | It is my intention to write this program in the [[wp> | + | This program |
- | initially thought that the [[http:// | + | had initially thought that the [[http:// |
- | be a good starting point, I've since come to the decision | + | module from CPAN]] would be a good starting point, I later decided |
- | be easier (for me). | + | from the ground up was easier (for me). |
- | As of 18 Nov 2007, I have written only the skeleton parser. | + | The program reads a GEDCOM file and stores all the relevant data in hashes. |
- | and report | + | then spits out a wiki page for each family (and any individuals who do not have |
- | nothing with the data. | + | families |
- | Here' | + | When I last uploaded this utility on 01 Feb 2009, I described its output as |
+ | "// | ||
+ | which rendered that statement entirely wrong! | ||
+ | **experimental**, | ||
- | < | + | The latest version of the program can be found here: {{:ged2wiki.zip|}} |
- | # | + | |
- | # Ged2Wiki.pl - Perl program to convert a GEDCOM file to plain text Wiki pages | + | |
- | # | + | |
- | # The input format is based on "The GEDCOM Standard" | + | |
- | # by the Family History Department of The Church of Jesus Christ of Latter-day | + | |
- | # Saints, 2 January 1996. | + | |
- | # | + | |
- | # The output format is a series of plain-text files based on DokuWiki | + | |
- | # | + | |
- | # For questions, comments, bug reports, etc., please visit this site: | + | |
- | # http://s560.com/ | + | |
- | # | + | |
- | my $currline; | + | An example |
- | my $nextline; | + | |
- | my $currlevel; | + | |
- | my $nextlevel; | + | |
- | + | ||
- | # Prime the parser by reading the first line | + | |
- | fetch_line(); | + | |
- | + | ||
- | # " | + | |
- | read_line(); | + | |
- | + | ||
- | # The first line must be "0 HEAD" | + | |
- | if ($currline !~ /^HEAD/) { | + | |
- | print "Input does not appear to be a GEDCOM file\n"; | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # First line is good. Parse the rest of the header | + | |
- | parse_header(); | + | |
- | + | ||
- | # If it's a Submission record, parse it here | + | |
- | if ($currline =~ / | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # Loop here, reading the " | + | |
- | while (1) { | + | |
- | + | ||
- | # First, check for the Trailer record | + | |
- | if ($currline =~ /^TRLR/) { | + | |
- | last; # We're done with the input - break out of this loop | + | |
- | } | + | |
- | + | ||
- | # Each Record must be in this format | + | |
- | if ($currline !~ / | + | |
- | print " | + | |
- | exit; | + | |
- | } | + | |
- | my $xref = $1; | + | |
- | my $tag = $2; | + | |
- | + | ||
- | # If it's a " | + | |
- | if ($tag eq " | + | |
- | parse_family($xref); | + | |
- | next; | + | |
- | } | + | |
- | + | ||
- | # If it's a " | + | |
- | if ($tag eq " | + | |
- | parse_individual($xref); | + | |
- | next; | + | |
- | } | + | |
- | + | ||
- | # If it's a " | + | |
- | if ($tag eq " | + | |
- | parse_note($xref); | + | |
- | next; | + | |
- | } | + | |
- | + | ||
- | # If it's an unknown record, it's an error | + | |
- | if ($tag !~ / | + | |
- | print " | + | |
- | exit; | + | |
- | } | + | |
- | + | ||
- | # Ignore this type of record | + | |
- | | + | |
- | } | + | |
- | + | ||
- | print " | + | |
- | + | ||
- | # Generate all the output here ... | + | |
- | + | ||
- | exit; | + | |
- | + | ||
- | # Read one line from the input file (and strip unwanted whitespace) | + | |
- | sub fetch_line { | + | |
- | | + | |
- | | + | |
- | | + | |
- | if ($nextline !~ /^(\d+)\s+/) { | + | |
- | print " | + | |
- | exit; | + | |
- | } | + | |
- | | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # One input line -> $currline (concatenating as needed) | + | |
- | sub read_line { | + | |
- | + | ||
- | | + | |
- | | + | |
- | + | ||
- | # Special case: Do not read beyond the Trailer | + | |
- | if ($currline =~ /^TRLR/) { | + | |
- | $nextline = ""; | + | |
- | $nextlevel = ""; | + | |
- | return; | + | |
- | } | + | |
- | + | ||
- | | + | |
- | + | ||
- | while ($nextlevel == $currlevel + 1 && $nextline =~ /^CON([CT])\s+/) { | + | |
- | if ($1 eq " | + | |
- | | + | |
- | } else { | + | |
- | | + | |
- | } | + | |
- | fetch_line(); | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | # Parse the header | + | |
- | sub parse_header { | + | |
- | print ">> | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # Parse the submission record | + | |
- | sub parse_subn { | + | |
- | print ">> | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # Parse a Family record | + | |
- | sub parse_family { | + | |
- | print ">> | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # Parse an Individual record | + | |
- | sub parse_individual { | + | |
- | print ">> | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # Parse a Note record | + | |
- | sub parse_note { | + | |
- | print ">> | + | |
- | | + | |
- | } | + | |
- | + | ||
- | # Ignore this record | + | |
- | sub parse_ignore { | + | |
- | my $thislevel = $currlevel; | + | |
- | while (1) { | + | |
- | read_line(); | + | |
- | if ($currlevel <= $thislevel) { | + | |
- | | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
ged2wiki.txt · Last modified: 2013/01/06 15:48 by jims