RootsWeb.com Mailing Lists
Total: 1/1
    1. Re: Search and replace in one field
    2. Charlie Hoffpauir
    3. On Mon, 18 Feb 2013 19:08:16 -0500, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote: >On Mon, 18 Feb 2013 10:44:39 -0500, Denis Beauregard ><denis.b-at-francogene.com@fr.invalid> declaimed the following in >soc.genealogy.computing: > > >> Some lines may have an ID as 2nd field, then a tag as 3rd field. >> This is common with level 0. >> >> 0 @I1@ INDI >> 1 NAME Bernard /Landry/ >> 2 GIVN Bernard >> 2 SURN Landry >> 1 SEX M >> 1 BIRT >> 2 DATE 9 MAR 1937 >> 2 PLAC St-Jacques >> 0 @I2@ INDI >> 1 NAME Bernard /St-Jacques/ >> 2 GIVN Bernard >> 2 SURN St-Jacques >> 1 SEX M >> 1 FAMS @F1@ >> 1 FAMC @F2@ >> >> Example of processing : replace all St-Jacques in PLAC fields >> by "St-Jacques,,Qc," but not in NAME fields. > >PowerShell command (assuming there are none that already have extended >text)[UNTESTED] > >get-content >'path:to\file.ged' | foreach {$_ -replace >'(.) PLAC (.*) (St-Jacques) (.*)', '$1 PLAC $2 $3,,Qc, $4'} > >'path:to\new.ged' I'm impressed with both the Powershell and the AWK solutions to the problem Denis posted. However "that" problem I could also correct with traditional means, like a rather simple Word macro. However, as I explained in a follow-up to Denis's post, the actual problem that started the thread was a bit different. I'm sure either AWK or Powershell can handle it too, but I do think it's a bit more complicated. As someone "aspiring" to become proficient in either AWK or Powershell, I'd really like to see that solution posted. In general, the difference is that the original problem was to replace quote marks with some other character, when quote marks appear in the name field, for an "arbitrary" name. That is, it is assumed that some portion of the given names in the file, (but not all) have had quote marks surrounding one or more of the given names, and these are the characters that must be changed.

    02/18/2013 12:10:22