* Search and Replace on a Named List (or Similar)

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
zoomdoggies
Gold
Posts: 26
Joined: 25 Apr 2014 21:27
Family Historian: V6.2
Location: Seattle, Washington, USA

Search and Replace on a Named List (or Similar)

Post by zoomdoggies » 10 May 2017 22:01

Is there a way to run the Search and Replace plugin on a subset of the FH database? For example, is it possible to run Search and Replace on just the items in a Named List?

Here's what I want to do: For the events that occurred in Canada prior to 1763, I want to change the place "Canada" to "Canada (Nouvelle-France)". I've got a query that selects the events, and I can put them in a Named List.

What I don't want to do is make this change manually for each event, since there are 1448 of them. Isn't there an easier way?

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by tatewise » 11 May 2017 09:55

Unfortunately, the Search and Replace Plugin does not have options for that kind of subset.

Also the problem has other aspects you need to consider, because changing Place names involves the Place records.
This may both help you and hinder you.

If you simply change the Place field in any Fact then that will create a NEW empty Place record. Any details such as Latitude & Longitude, Media, Notes, etc, will only exist in the old Place record. Those old Place records may also end up with no Links and need to be removed.

Whereas, if you find the desired Place record and change its name, then all associated Facts get updated, and all the details are retained. So one small change will update all linked Facts.

So, your first task is to analyse the Facts found by your Query and determine which Place records are affected.
Sort by the Place name column and include the number of Place record Links i.e. =LinksTo(%FACT.PLAC>%)
Then for each Place record there are two possibilities :-
  1. The Place record is only used by Facts found by your Query and nowhere else.
    In this case, just edit the Place record name, and all the Facts will follow suit.
  2. The Place record is also used by Facts NOT found by your Query.
    In this case you will need to create a new Place record and copy any details from the old Place record.
    Ensure the Place name of the old record matches the majority of Facts to minimise the number of edits.
    Then migrate the other Facts to the new Place record by editing one by one.
If any of the above is not clear then please do ask again.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by Jane » 11 May 2017 10:14

Another option would be to write your own plug in to loop through the facts checking the date and place and changing if needed.

It's probably worth noting Named Lists only contain links to records and not links to specific facts.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by tatewise » 11 May 2017 10:22

But such a Plugin must take account of the Place record issues I mentioned.
e.g.
If the Plugin simply changes the Place record name associated with the first Fact that matches the criteria, then EVERY Fact that uses that Place record will change whether it matches those criteria or not.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by Jane » 11 May 2017 16:59

Actually you can use a plug in to do it, just change the place record which is linked to the new one.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by tatewise » 11 May 2017 17:31

Yes, I didn't say a Plugin can't do it, just that it must take care with the Place records.
I guess it could clone the old Place record into a new Place record that only differs in its name.
Then link that new Place record to each Place field that matches the criteria.
It must keep track of all the old and new Place names and use the appropriate new Place record where needed.
Finally, it could delete any old Place records with no links.

The point is that it's not a simple search and replace, but involves Place record management.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
zoomdoggies
Gold
Posts: 26
Joined: 25 Apr 2014 21:27
Family Historian: V6.2
Location: Seattle, Washington, USA

Re: Search and Replace on a Named List (or Similar)

Post by zoomdoggies » 11 May 2017 17:49

Mike and Jane,

Thanks for the information. Those are pretty much what I figured my options were; I just wanted to make sure I wasn't overlooking something obvious.

Mike's option 1 will take care of some of the Facts I want to update – those Place records referenced only by Facts found by the Query, and not used anywhere else.

The remaining 979 Events might be worth writing a plugin. Although my script-writing skills are at about the "Hello, World!" level of competency, I've been meaning to explore the possibilities that plugins offer, and this is a good excuse. I'm finding the prospect less daunting than it might otherwise be because of the meticulous job you've both done in commenting the existing plugins. Very helpful!

This will be fun.

Teri
Last edited by zoomdoggies on 11 May 2017 20:29, edited 1 time in total.

User avatar
Valkrider
Megastar
Posts: 1534
Joined: 04 Jun 2012 19:03
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by Valkrider » 11 May 2017 18:59

Just a thought what about splitting your tree and creating two. One with the records you need to change and the other with the ones you don't. Change the place records with Search and Replace. Then merge the two trees back into one.

You may need Mike or Jane to confirm this will work or you could try it on a copy of your project.

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Search and Replace on a Named List (or Similar)

Post by tatewise » 11 May 2017 20:37

Nice idea Colin, but I am not sure the split neatly fits records because the split is for Facts that match Place & Date criteria.

Teri, if you need any advice for the Plugin then just ask.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
zoomdoggies
Gold
Posts: 26
Joined: 25 Apr 2014 21:27
Family Historian: V6.2
Location: Seattle, Washington, USA

Re: Search and Replace on a Named List (or Similar)

Post by zoomdoggies » 11 May 2017 21:32

Thanks, Mike. I'm pondering the advice you've already offered:
tatewise wrote:…. Guess it could clone the old Place record into a new Place record that only differs in its name.
Then link that new Place record to each Place field that matches the criteria.
It must keep track of all the old and new Place names and use the appropriate new Place record where needed.
Finally, it could delete any old Place records with no links.
I should probably start with something less ambitious, but what would be the fun in that? I can take it piece-wise, and see how far I get. Although it will almost certainly take me longer and cause more aggravation to write a plugin then it would to do the task by hand, by the time it's done – or I give up – at least I'll know something about writing plugins. I already know more than I did.

Teri

Post Reply