Page 1 of 1

Bulk Deletion of Census Event Note field

Posted: 04 Dec 2009 17:29
by tithepit
Apologies in advance if this has been asked & answered before but I cannot find a similar question so here goes.

I have made extensive use of the excellent GedCom Census tool but in the past have opted to use the facility to Copy the source text (of the census record) into the Note field of the census event for each individual. To be fair I should point out that this was not recommended practice but it seemed to me to be a good ideas at the time.

I have now seen the error of my ways and turned off this option but of course I am still left with many hundreds of individuals each with many census events each with this source text note.

This idea of deleting these notes by hand is daunting so can anyone suggest how they may be deleted in bulk? The nearest thing I've found is the Split Tree Helper which would delete the individuals or the events but I cannot find a way to leave the event in pace but just delete the associate note.

Any suggestions please?

ID:4203

Bulk Deletion of Census Event Note field

Posted: 04 Dec 2009 18:25
by nsw
If no one comes up with an easier solution in the next 24 hours if you want to email your GEDCOM file to me I'll delete every local note attached to a census event if you're sure that's what you want. I can do this reasonably easily programmatically.

Nick

Bulk Deletion of Census Event Note field

Posted: 04 Dec 2009 19:07
by PeterR
I think the easiest way to delete all occurences of a particular field is to use a Query; this has worked since version 2 of FH (and I'm sure Jane has posted this advice before).

As always, be sure to backup your file first!

You need a really simple Custom Query which by default will be for Individuals.
Specify the column you need to delete, in this case Census Note,
i.e. %INDI.CENS.NOTE2%.
Specify a Rows Filter as follows:

Code: Select all

Add unless %INDI.CENS.NOTE2% is null
Then run the query and check that the displayed column contains the field to be deleted.  Then highlight all the entries in that column and press delete.[smile]

Bulk Deletion of Census Event Note field

Posted: 04 Dec 2009 19:10
by nsw
Nice one Peter, I had a feeling there was an easier way :)

Bulk Deletion of Census Event Note field

Posted: 04 Dec 2009 20:04
by margarita
tithepit

I was on the point of asking the same question, but I think you phrased it better.

Would you please let us know if you follow Peter's advice and what the outcome is. It seems a bit daunting to me. Will you be the guinea pig?

Regards,

maggie

Bulk Deletion of Census Event Note field

Posted: 04 Dec 2009 21:41
by PeterR
The use of Queries to delete multiple fields (and even to delete multiple records!) is in fact mentioned at the end of Chapter 13 of Getting the Most From Family Historian 4.  Obviously you have to check carefully what you are about to delete, and must always backup first.

Bulk Deletion of Census Event Note field

Posted: 05 Dec 2009 16:47
by tithepit
Firstly let me express my appreciation for the quality and timeliness of all the responses to my query. Again in my defence let me add that I have already put the recommended book 'Getting the Most From Family Historian 4' on my Christmas list! As soon as I saw it was coming out in print I know that it would be useful.

Let me now describe step by step what I did and the results:
  • Copied my Gedcom file to a file to experiment on
  • Created the query as outline above
  • Ran the query and checked the results by eye
  • Save the result set to file for later reference
  • Selected the 451 notes records listed and deleted them all in one go via the edit menu
  • Re-ran the custom query and found the result set empty
  • Ran up a second copy of Family Historian and loaded the original GedCom file to compare with copy edited as above
  • Observed that many Census Notes fields were no longer present
  • Also noted that many Census Notes fields are still present!
I then closed down FH and compared the two GedCom files in a text editor to see the difference between those Notes remaining and those which had been deleted from the original GedCom.

At this point I have to say that I nearly had to give up since I could not see any difference between Notes fields deleted by the query and those which are left. Just before sending this response it dawned on me that in each case it was the note field from the first instance of a census record which has been deleted. I now realise that this occurred because this is precisely what the query was designed to do since by default INDI.CENS actually refers to INDI.CENS[1] and only CENS[1].

Reading the soft copy of the 'Making the Most...' guide I believe that I now understand how to edit the query to add the second, third and so on census events - as follows:
  • %INDI.CENS[1].NOTE[1]%
  • %INDI.CENS[2].NOTE[1]%
  • %INDI.CENS[3].NOTE[1]%
  • etc.
But IMHO it would be better if it were possible to use a wild card in the field name (and I've wanted to do this elsewhere for other reasons where there are multiple fields of the same type). Is this possible or do I have to extend the query by just adding extra lines for each of up to 8 UK Census events? I've checked but cannot see that the guide  describes how to achieve this.

Bulk Deletion of Census Event Note field

Posted: 05 Dec 2009 18:12
by Jane
You can list all the Census events in Rows with the new fact queries, but I am not sure you can still use the delete function on those.

Don't forget you can simply duplicate the column and just edit the number, you only need to do this process once, so it should not take long to simply run the query 6 or 7 times incrementing the number each time.

Bulk Deletion of Census Event Note field

Posted: 05 Dec 2009 19:03
by PeterR
Thanks for the reminder about Fact Queries, Jane. Yes, you can delete multiple fields using a Fact Query, e.g. with the following columns:Imageand the following Rows filter:ImageThis is probably quicker than running several Individual queries.  Sorry I didn't suggest it originally.

Bulk Deletion of Census Event Note field

Posted: 06 Dec 2009 15:40
by tithepit
Thanks once again to both Jane and Peter for another set of excellent ideas - I went with Peter's suggestion - thereby learning about using both Fact Queries and Functions! This time the query was able to identify no fewer than 888 superfluous Notes fields and delete them all at a stroke!

The latest instructions for those wishing to emulate my success are set out here for reference:

# Copied my Gedcom file to a file to experiment on
# Created the query as outline above
# Ran the query and checked the result set by eye
# Save the result set to file for later reference
# Sorted by results by Notes field and ignored two records containing other Census Notes (which I wished to keep)
# Selected the 888 notes fields listed within the relevant column
# Deleted the unwanted notes fields all in one go via the edit menu
# Re-ran the custom query and found the result set empty
# Ran up a second copy of Family Historian and loaded the original GedCom file to compare with the copy edited as above
# Checked the results using 'ExamDiff' to compare GedCom files
# Observed that all Census Notes fields were no longer present
# Renamed the original GedCom file as backup and renamed edited version as 'primary file'

BTW I located and downloaded the 'ExamDiff' tool expressly for comparing the GedCom files before and after the deletion and found it to be an excellent tool for the purpose especially when set to 'show differences only' view.

Once again thanks to all those offering help which enabled me to rid my GedCom of all those unwanted fields, saving nearly six thousand rows in the process and reducing the resulting file size by almost one third.

Now I'm off to do battle with those UDF fields which I've just discovered as a hangover from years ago (before my enlightenment) when I struggled with The Master Genealogist!