* How can I perform bulk changes on source citations

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

How can I perform bulk changes on source citations

Post by Gowermick » 09 Nov 2015 16:01

I have multiple uses of a citation:-
Ancestry[6] "England & Wales, National Probate Calendar".

I have created a new citation Probate Register[42] and wish to use this to replace the above citations.

Is there a way to do this in bulk?
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 09 Nov 2015 18:41

The easiest way would be to edit the Ancestry[6] "England & Wales, National Probate Calendar" Source record such that it holds all the fields derived from the Probate Register[42] Source record. (This assumes that old Source record is now redundant.)

Then you can delete the Probate Register[42] Source record.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 09 Nov 2015 20:07

Mike,
Sorry, you have it the wrong way round. Ancestry[6] is used as the source for around 1200 citations, and I wish to change only some of these citations to the new Probate[12] Source, leaving Ancestry[6] for the remainder.

I know I can change these manually, by right clicking the source, Ancestry[6], and changing the source to Probate[12], but I wondered if there was a way of doing a bulk change.

Mike
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 09 Nov 2015 20:28

Sorry, I cannot think a manual method for doing that in bulk, and even a Plugin would need to know how to identify which Citations to change.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 11 Nov 2015 17:01

Mike,
A plugin could work if one assumes the new Citation contains all necessary data, and nothing needs carrying over from old citation. The old citation is known (Ancestry[6]), and the ones needed to be changed to new citation (Probate[42]), all have same text in 'where within source'.

In pseudo code terms, and using my case as an example, the changes necessary would look like:

repl all Source[6] (and all its associated fields) with Source[42] where Source[6] field 'wherewithinsource' contains "Probate Calendar"

I'm sure that is well within capabilties of a plugin. It could even be made universal by requesting source and destination citations from user, as well as requesting the criteria needed to perform the change.

When I get more familiar with LUA, the FH6 API and its data structures, I may even give it a stab myself. It may be a steep learning curve to overcome, so don't hold your breath!
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 11 Nov 2015 22:50

Excellent! With that detail, give me a few days and I should be able to write the Plugin which will give you some insight into LUA.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 12 Nov 2015 06:29

Many thanks Mike. I look forward to looking at the code.

Mike
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 12 Nov 2015 15:25

I have a prototype Plugin working, but I have one question.

You said "new Citation contains all necessary data, and nothing needs carrying over from old citation".

But you may not be aware of the distinction between Citation details and Source record details.
Fields such as Entry Date, Assessment, Where within Source, Text From Source, and Note shown in the yellow Sources pane are integral with the Citation.
Whereas, the Source record holds Title, Author, Publication Info, different Text From Source, and Note, etc.

So the question is: When the Source record is replaced what should happen to those integral Citation fields?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 12 Nov 2015 19:02

Mike,

In this case, there is nothing of significance in the source, literally the title Ancestry and 'where within source' containing "National Probate Calendar......" so can safely be deleted.
Doing it manually, I replaced the link to Ancestry[6] with Probate[42], then deleted all the subsidiary fields. Obviously, this might not always be the case.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 12 Nov 2015 19:20

OK Mike, when dealing with Plugins and the Gedcom structure we need to be extemely precise.

You said: "there is nothing of significance in the source, literally the title Ancestry and 'where within source' containing "National Probate Calendar......" so can safely be deleted."

But you mean the Citation literally links to the Source record Ancestry[6] and Where within Source contains National Probate Calendar.......

Earlier you said Where within Source contains Probate Calendar.

Currently, the Plugin is matching the whole Where within Source field exactly with a specified text string.
But it sounds like the Where within Source field could contain various text strings that have Probate Calendar embedded within them somewhere.

I can easily change the Plugin to match when a specified text string occurs anywhere in the Where within Source field. Is that what you require?

Also, when the Source link is replaced you also want the Where within Source field deleted?

Do you want all the other Citation fields deleted or not, or perhaps a tick option to choose?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 12 Nov 2015 19:32

You are correct in your assumption, the 'where within source' field contains the phrase "Probate Calendar" somewhere within the field, which may contain additional text!

I think it would make the plugin more useful/universal if the user was given the option to delete certain fields, rather than delete them all willy-nilly.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 13 Nov 2015 23:23

Please find the ATTACHMENT Replace Selected Source Citations Plugin Version 0.1 Dated 13 Nov 2015. Click the link to install into FH.

It is advisable to use File > Backup/Restore > Small Backup before running Plugin just in case! Alternatively, run the Plugin on a copy of your Project.

The Plugin will request the Old Source to be replaced, and the New Source replacement.
It offers Citation Options to choose what text some fields must contain and the fields to delete.
Leaving a text field blank means it can contain anything or nothing.
Currently there is no filter option to require a field to be empty.
When complete it lists all Citations that changed. Double-click them to see results.

To cancel all changes use Undo > Plugin Updates after running Plugin but before closing FH.

[EDIT: ATTACHMENT deleted because now in Plugin Store.]
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 14 Nov 2015 10:30

Please find in ATTACHMENT revised Replace Selected Source Citations Plugin Version 0.2 Dated 14 Nov 2015. Click the link to install into FH.

This version fixes a minor problem with handling Unicode UTF-8 characters in FH V6.
It also allows the Text From Source and local Note fields to match multiline text.
Also some coding efficiency and extensibility added.

All the same caveats and advice apply as before.

Do you need to be able to match Entry Date &/or Assessment values?

[EDIT: ATTACHMENT deleted because Plugin now in Plugin Store.]
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 14 Nov 2015 11:09

Mike,

Many thanks, I'll give it a look when I boot my PC.
As for the 'entry date' and 'assessement', the answer is no at present, but to make it more generic, perhaps they ought to be catered for. I'll leave it up to you.

What IDE / editor do you use for coding? I found Geany can read lua code, and colour codes it well, and also matches blocks, functions etc, which can be minimised at will.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 14 Nov 2015 14:02

I use the FH built-in Tools > Plugins > Editor/Debugger which is essential to access the FH API and installed library modules. See the Plugins How to Write Plugins Help and the FHUG KB for Plugins.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 19 Nov 2015 23:37

Did the Plugin work for you?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: How can I perform bulk changes on source citations

Post by Gowermick » 20 Nov 2015 06:37

Mike,
Sorry, remiss of me not to reply sooner.

Yes indeed it did work very well, and I have been busy using it to tidy my GRO references!
Originally I had them all under a single GRO source, but wanted to break them down into manageable sizes, by splitting them into three (GRO B, GRO M and GRO D). Your plugin handled it very well, thank you.

I haven't spotted any drawbacks, so suggest you could release it to the general population.
Again, many thanks.

Mike
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 22 Nov 2015 19:05

Thanks Mike.
I have updated the Plugin to support matching the Assessment field, and reorganised the Citation Options dialogue, which I think is now easier to understand, and ready to publish to the Plugin Store.

A further refinement lists the five key Citation fields in the Resut Set for easier review.

[EDIT: ATTACHMENT deleted because Plugin now in Plugin Store.]
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

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

Re: How can I perform bulk changes on source citations

Post by tatewise » 27 Nov 2015 14:53

The Replace Selected Source Citations Plugin Version 1.0 is now in the Plugin Store.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply