in reply to Converting GEDCOM files

I can't quite get the jist of what you want with the SOUR part. As you are a fellow Aussie I will post a solution for you if you post: A sample of the SOURCE file with a corresponding example of how the OUTPUT should look. Add any notes before, after but not in the SOURCE and OUTPUT.

Here is some code to do the first bit you want. You will need perl to use this. For details on getting perl see New Monks part 7. Do you want the latest version of Perl?

#!/usr/bin/perl -w use strict; my @data; # define a hash of changes to be made my %change = ( HEAL => 'NOTE Medical:', HIST => 'NOTE Biography:', EDUC => 'NOTE Educated:', RESI => 'NOTE Resided:', OCCU => 'NOTE Occupation:', ); # accept input via three mechanisms # if no file specified here: my $file = ''; # then look for a command line argument here: $file = shift @ARGV unless $file; # if we still have no file to process # enter interactive mode here: unless ($file) { print "Please enter a file to process: "; chomp($file = <>); } # get the data open (FILE, "<$file") or die "Unable to open $file: $!"; @data = <FILE>; close FILE; # make the changes for (@data) { for my $key (keys %change) { s/$key/$change{$key}/g; } } # print the changes to a new file with the same name # as the original plus a .new suffix. open (FILE, ">$file.new") or die "Unable to write $file.new: $!"; print FILE @data; close FILE; print "Munged $file no worries!\n";

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Converting GEDCOM files
by Joes (Acolyte) on Jul 08, 2001 at 02:28 UTC
    Thanks Tachyon -your offer is very much appreciated. I am brand new to this Monastery, so how do I contact you to send a sample .ged file? PS liked your hang glider - flying for 20 years? and still around to tell the tale??

      Yes still here. </BEGIN_RANT> Stats are that you are about twice a likely to kill yourself in a hang glider as in a car. However it is about 5 times safer than riding a motor bike. Twice as safe as horse riding..... Life is a terminal disease you know </END_RANT>

      Anyway I have added an email link to my home node at the bottom so if you don't want to post details here (which would be considered usual) then send it to me there. It is generally considered proper netiquette to continue this discussion in this forum rather than in private but as everyone knows we Aussies have no manners :-) Some of the advantages of doing things in a open forum include allowing others to learn from the discussion, getting second, third,.... opinions on the quality of the code and advice presented. Allowing Monks to show off their skills to their peers is also a big part of how this site works.

      To post files here you use insert the <code> and </code> tags into your text. You just put the file between these tags where the 'and' is and then we can hit a button and download the lot.

      When munging a text file from one format to another the key thing is to know what it looks like now (the source) and what you want it to look like (the output). If you supply that along with the explanation already posted then it should only take a few minutes to complete the program, says he laughing in the face of the God of unforseen consequences!

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

        Thanks Tachyon. I would gladly print the data on this site, but I thought that would be too much data, and contrary to etiquette. I admire your condfidence in all things - I am an ex Harley 750 and Bonneville 650 man myself, but age has taken over (plus eroded vertebral discs) You obviously haven't met Murphy in your life - either that or you have successfully snubbed him!! Many thanks, Joe.
        Thanks tachyon for the script for converting Reunion 4.0 GEDCOM to be compatible with PAF 5.0. - it is very clever and imaginative and clearly shows the strengths of Perl - anyway, it is to an ex Fortran / Pascal programmer, many years ago. I appreciated the detailed documentation, and the time and effort involved, especially when my specification conflicted with the output demo. Your script is also a good learning tutorial for me. It is this response that makes this Monastery so professional and held in such high regard. Many thanks. Please feel free to publish the script.