* Parallel Family Historian and Ancestry trees

Importing from another genealogy program? This is the place to ask. Questions about Exporting should go in the Exporting sub-forum of the General Usage forum.
User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Parallel Family Historian and Ancestry trees

Post by Mark1834 » 11 Nov 2018 19:42

Apologies if I’m stating the obvious, but until you are sure the modified script is doing what you expected, it is always prudent to work with a copy of your database, not the original.

I found it convenient to create a C:\Python\Data folder and copy my GEDCOM file there. Send output to the same folder. To run, open a command window, navigate to that folder, and run the script just by entering py yourscript.py. Minimises typing, and once working as planned, update with your actual input and output files and modify the batch file.
Mark Draper

User avatar
David2416
Superstar
Posts: 378
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Parallel Family Historian and Ancestry trees

Post by David2416 » 11 Nov 2018 20:28

Hi, I have download the original file again and edited using notepad:

The output from running my batch file is:
batch output.jpg
the two changed lines (using Notepad) are:

input_file = 'C:\Users\David\Documents\Family Historian Projects\David\David.fh_data\David - Copy.ged'
output_file = 'C:\Users\David\Documents\Family Historian Projects\David\David.fh_data\David Ancestry Update.ged'

and the first few lines of my FH Gedcom copy (opened in notepad)

0 HEAD
1 SOUR FAMILY_HISTORIAN
2 VERS 6.2.7
2 NAME Family Historian
2 CORP Calico Pie Limited
1 FILE C:\Users\David\Documents\Family Historian Projects\David\David.fh_data\David.ged
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
2 _VAR VUL
1 CHAR UNICODE
1 DEST FTM
1 SUBM @U1@

Does this help in anyway?

Regards
David

PS I'm a bit puzzled by the line 1 DEST FTM

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Parallel Family Historian and Ancestry trees

Post by Mark1834 » 11 Nov 2018 23:10

Thanks for that. I have a hypothesis that I would like to test, please.

Attached is a modified script file, plus a copy of the Family Historian Sample Project.ged data file. Could you please save both of these directly to a C:\Python\Data folder, and run directly from the command line (without any modification) by entering py FH2Ancestry101.py. My output from this is shown below:
Capture.PNG
Capture.PNG (8.11 KiB) Viewed 7156 times
If this works correctly, please edit the script file to use your own data file and repeat. If that run ok, everything is fine. If you still get errors, rename the sample project file to something else, and modify the script to refer to this new file name. If the errors persist, the problem must be something in the script file formatting rather than the data file, as the data file is known to work correctly.
Attachments
FH2Ancestry101.py.txt
(4.88 KiB) Downloaded 176 times
Family Historian Sample Project.ged
(140.58 KiB) Downloaded 198 times
Mark Draper

User avatar
David2416
Superstar
Posts: 378
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Parallel Family Historian and Ancestry trees

Post by David2416 » 12 Nov 2018 07:43

Will give that a go. Thanks.

User avatar
David2416
Superstar
Posts: 378
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Parallel Family Historian and Ancestry trees

Post by David2416 » 12 Nov 2018 09:14

Hi Mark,
The screenshot shows the results of my trials:
batch output 2.jpg
The first run is is using your test files as instructed. All well
The second run is amended the script to run with my files in their original location. Fail
For the third run I copied my files to C:\Python\data folder, script adjusted accordingly. A successful run :)

It seems the problem lies with the file path. :?:

Regards David

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

Re: Parallel Family Historian and Ancestry trees

Post by Jane » 12 Nov 2018 10:16

try using \\ rather than \ in the path.

You need to escape the backslashes, alternately forward slashes will probably work.
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: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Parallel Family Historian and Ancestry trees

Post by tatewise » 12 Nov 2018 10:44

Jane, that should not be necessary in Python scripts, and is not the case in Mark's scripts.
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: Parallel Family Historian and Ancestry trees

Post by Jane » 12 Nov 2018 10:51

Fine, when I googled Python and backslash it suggested the escaping was required.
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
David2416
Superstar
Posts: 378
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Parallel Family Historian and Ancestry trees

Post by David2416 » 12 Nov 2018 13:13

Will test that out and report back, probably tomorrow now, as at work

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Parallel Family Historian and Ancestry trees

Post by Mark1834 » 12 Nov 2018 17:17

I think we are sorted now, thanks to all for testing and inputs. Trial and error experimenting and a bit of internet research gave me the following:

The key difference between what worked and what didn't was the Windows path and filename. Back-slashes do not routinely need escaping in Python, but do when the combination with the following character is interpreted as a special character or control code.

'C:\Python\Data\David - Copy.ged' is fine, as neither \P nor \D have any special meaning. The "gotcha" for most Windows users is that \U is the prefix for a 32-bit Unicode character, so any absolute path along the lines of 'C:\Users\MyUserName\Documents...' will fail!

I hadn't noticed that before, as my default Documents folder is remapped to OneDrive on a separate drive, so my absolute path of 'D:\OneDrive\Documents\Family Historian Projects\Draper\Draper.fh_data\Draper.ged' is ok as none of \O, \F or \D have any special meaning so do not need escaping.

The fix is either to double back-slash throughout (so 'C:\\Users\\MyUsersName\\Documents...') as superfluous double back-slashes do not do any harm, or prefix the pathname with a lower case r, as in

input_file = r'C:\Users\MyUserName...'

This causes Python to regard what follows as a "raw string", i.e. a string literal, so all characters are interpreted as written, with no special meanings. The alternative work-around of using a forward slash, as in most other operating systems, is fine for standard Python, but does not work with the codecs library that is required to handle the UTF-16 GEDCOM file that is the FH default.

If we get positive reports from (ideally several) users that this works ok, I can upload a new master copy of the script. It is worth keeping the modification introduced in version 1.01, as this has Windows style CR/LF line endings that work in any text editor. The original version was written on a Linux machine, so while the Unix-style single byte endings don't cause any problems for any half-decent modern text editor, Windows Notepad doesn't tick either of those boxes, so can't display the file properly.
Mark Draper

User avatar
David2416
Superstar
Posts: 378
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Parallel Family Historian and Ancestry trees

Post by David2416 » 12 Nov 2018 20:00

Wonderful, so now the error message makes sense. Bit of a Gordian knot methinks. Thank you Mark.

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

Re: Parallel Family Historian and Ancestry trees

Post by tatewise » 15 Nov 2018 20:10

The Export Gedcom Plugin - Resizing media (16281) posting has an updated Plugin V3.6.3 prototype that fixes the problem of Roots Magic not supporting blank Individual names.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
David2416
Superstar
Posts: 378
Joined: 12 Nov 2017 16:37
Family Historian: V7
Location: Suffolk UK

Re: Parallel Family Historian and Ancestry trees

Post by David2416 » 17 Nov 2018 07:37

Just an update, have run the script successfully. Loaded into Roots Magic and looks good. Been too busy this week to progress further. Many thanks, think this will prove to be very useful.

Post Reply