PDA

View Full Version : Search and replace with Grep in BBEdit in a GEDCOM file


marian
19 September 2005, 04:33 PM
Hello,

from the Windows genealogical application The Master Genealogist I exported a GEDCOM file where the places are in the form
Detail, City, County, State, Country
So I have such tags:
2 PLAC St. Remy Abbey, Reims, Marne département, Champagne-Ardennes région, France
but also
2 PLAC , Vienne, , , France
Reunion imports the second tag as Vienne, France

The problem I have is that I need this file imported back in The Master Genealogist and to verify (and change) events for more then 2300 people is a hard work.

I have here the application BBEdit and it can search and replace with Grep. I need a little help from somebody to find the search sentence for the lines which begin with 2 PLAC the empty places and a sentence to replace the empty places with something like "replaced by BBEdit" or so.

Perhaps can somebody help me for this.
Thank you very much,
Marian Boangiu

MHill
20 September 2005, 09:10 AM
I'm no GREP expert, but I'd use three separate replaces. Here's what I came up with:

Perform 3 times (to change middle place fields):
Search: ^(2 PLAC )(.*), ,
Replace: \1\2, replaced by BBEdit,

Perform once (to change first place field):
Search: ^2 PLAC ,
Replace: 2 PLAC replaced by BBEdit,

Perform once (to change last place field):
Search: ^(2 PLAC )(.*),( *)\r
Replace: \1\2, replaced by BBEdit\r

I can't find a way to format this to show a monospaced font for the code (similar to the code html tag), so it's hard to see the spaces.

Obviously, if you decide to try my suggestion, use a copy of the original file. When I'm trying to figure out a GREP pattern, I undo right after the replace if it didn't do what I expected and I make a change and try again. Somebody else might post a better suggestion, but this is what I came up with.

After you've made your changes, you can use BBEdit to compare the original and modified files. (Search>Compare Two Front Documents)

Michael

marian
21 September 2005, 01:03 PM
Thank you very much Michael!

It works very good.
Now I can replace in Reunion replaced by BBEdit with no letter and I have the places in the form I need to export back.

Thank you again,
Marian Boangiu