* Change full date to FH date

Homeless Posts from the old forum system
Locked
User avatar
Debbie
Platinum
Posts: 47
Joined: 24 Feb 2008 14:50
Family Historian: V7

Change full date to FH date

Post by Debbie » 16 Feb 2011 21:05

I have just imported a GEDCOM from someone who has entered all dates in the full format ie 27 October 1893. FH has interpreted these as a date phrase and put them in quotation marks.

Is there a simple way to change them to the FH accepted way? (Hope so! [eek])

ID:4998

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

Change full date to FH date

Post by tatewise » 16 Feb 2011 22:12

Assuming you still have the ORIGINAL GEDCOM file you could perform a text editor find & replace.

Use a text editor such as Windows Notepad or better still PSPad available here http://www.fhug.org.uk/wiki/doku.php?id ... pad_editor.

Make sure you have a backup copy of the original GEDCOM file in case of mistakes.

Open the original GEDCOM .ged file with your text editor and use a global search & replace to change January into JAN, and February into FEB, etc, etc, and then Save the file.

This may also change the months in plain text fields, but you can deal with them as and when you find them later in FH.

Open the edited GEDCOM with FH and the dates should be OK.

If you only have the GEDCOM after being Saved by FH, then you will also have to remove the parentheses ( ) that have been added around each date.
This is more problematic because parentheses may occur elsewhere.
If you are prepared to use Regular Expressions then I could explain how to use PSPad to make sure only date parentheses are removed.

User avatar
Debbie
Platinum
Posts: 47
Joined: 24 Feb 2008 14:50
Family Historian: V7

Change full date to FH date

Post by Debbie » 16 Feb 2011 22:22

I have still got the original GEDCOM, so the text editing way should work. Will give it a try tomorrow. Thank you so much for your help.

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

Change full date to FH date

Post by Jane » 17 Feb 2011 08:15

Just to add if you use PSPAD, you can use the list feature on the search before doing the replace to find any month names you might want to change back once the replace is done.

User avatar
Debbie
Platinum
Posts: 47
Joined: 24 Feb 2008 14:50
Family Historian: V7

Change full date to FH date

Post by Debbie » 21 Mar 2011 21:05

I have tried the search and replace, but unfortunately the GEDCOM had been saved before I received it, with the parentheses round the dates!
If you are prepared to use Regular Expressions then I could explain how to use PSPad to make sure only date parentheses are removed.
Thank you for this offer - I would be grateful if you could explain how to remove them!

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

Change full date to FH date

Post by tatewise » 21 Mar 2011 23:13

You need to install PSPad because simple text editors like Notepad do not support Regular Expressions.
Follow the download and installation instructions given in the Knowledge Base at:
http://www.fhug.org.uk/wiki/doku.php?id ... pad_editor

Ensure you have a backup copy of your original GEDCOM file.
Run PSPad and use File > Open to open your original GEDCOM (.ged) file.

Use Search > Replace to open the Replace pop-up window.
Clear the tick against Case Sensitive
Set the tick against Prompt Each Replace
Set the tick against Regular Expressions

Now here are the Regular Expression edit strings:
Find:                  2 DATE (([0-9]{1,2}) JANUARY ([0-9]{4}))
Replace:      2 DATE $1 JAN $2

I suggest you copy & paste these into the Find: & Replace: boxes.

Click on the List button and all matching occurrences will be listed in the Search Results pane below.

Use Search > Replace to open the Replace pop-up window again and re-enter settings.
Click on the triangle at right-hand end of Find: & Replace: boxes to select previous edit strings.
Click on the OK button and check replacement, then click Yes to confirm.
When confident that all is OK, clear the tick against Prompt Each Replace and click OK to replace all remaining occurrences.

Repeat the above process eleven more times to replace FEBRUARY with FEB, MARCH with MAR, through to DECEMBER with DEC.

Use File > Save to preserve your changes and check in FH.

Click on the ? at top right of Replace window for help on Regular Expressions.

How does this particular Regular Expression work?

The Find sub-strings are explained in turn:
2 DATE                        represents itself
(                                    represents ( which is 'escaped' with to force its literal meaning
[0-9]{1,2}                  represents 1 or 2 digits 0-9 for day of month
JANUARY            represents the month itself
[0-9]{4}                        represents exactly 4 digits 0-9 for the year
)                                    represents ) which is 'escaped' with to force its literal meaning

The 'day of month' and the 'year' sub-expressions are enclosed in parentheses ( ) as explained below.

The Replace sub-strings are explained in turn:
2 DATE            represents itself
$1                        represents the 1st sub-expression for 'day of month' found above
JAN                  represents itself
$2                        represents the 2nd sub-expression for 'year' found above

I hope that makes sense and it all works OK for you.

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

Change full date to FH date

Post by tatewise » 22 Mar 2011 10:37

REVISION

I must have been tired yesterday evening, and a few oversights crept in.
Here is the revised Regular Expression edit:
Find:            ([1-9]) DATE (([0-9]{0,2}) {0,1}([A-Za-z]{3})[A-Za-z]{0,6} ([0-9]{4}))
Replace:      $1 DATE $2 $3 $4

This caters for various DATE tag level number values, allows the day of the month to be missing, and automatically truncates every month to the leading three characters so only one edit pass is required.

This is the explanation:
Find string   Replace    Sub-expression explained
([1-9])             $1         DATE tag level number 1-9
([0-9]{0,2})       $2         optional day of month 0 to 2 digits 0-9
{0,1}                             optional space character
([A-Za-z]{3})    $3          leading 3 month letters
[A-Za-z]{0,6}                 trailing 0 to 6 month letters
([0-9]{4})          $4          four year digits 0-9

Hope this does the job.

User avatar
Debbie
Platinum
Posts: 47
Joined: 24 Feb 2008 14:50
Family Historian: V7

Change full date to FH date

Post by Debbie » 22 Mar 2011 21:48

Thank you so much Tatewise for taking the trouble to work this out for me.

I have to confess to getting a little bit of help from my son, but it did fix the problem, all except the ones with a th after the date that is!

Anyway, saved me loads of time. Thanks again.

Locked