When I started using Gramps (older versions 3 & 4) for my family tree, I chose to use the Title field to store their occupation information. Gramps since version 5 offers the capability to print the last occupation event in the relationship graph so I decided to migrate my existing data to a proper occupation event. As I have 900+ persons in my family tree, I would like to automate the process. Here is how I plan to do things:
- query the persons database to get the title field data as well as the person id
- process this data to a nice input file (I need to reformat the title information as sometimes I recorded several jobs at once)
- create occupation events from my input file
I am familiar with python and programming in general but I don't know how to interact with Gramps files. Are there example code or documentation I could use to understand how data is organised?
Better ideas accepted.
EDIT Note : I am currently using v5.0.1
After some research, I know how to do the step 1 above: by using the export menu I can generate a csv where I can find the title and the person id straigth-away. Step 2 is just me cleaning the data so that's ok. However for step 3, I am stuck. It looks like I could use the import feature if I was able to generate an xml file in the same format as Gramps. The problem is that Gramps expects something like this:
<person handle="_cd284dd52627d55ab80" change="1554508105" id="I0010"> ... <eventref hlink="_e235f0096da3481aebdc5bf0138" role="Primary"/> ... </person> <event handle="_e235f0096da3481aebdc5bf0138" change="1554508051" id="E1346"> <type>Occupation</type> <dateval val="1892"/> <description>Teacher</description> </event>
And I have no clue on how to generate the
hlink values so that they don't break Gramps database. I also don't know what happens if I import partial information, does it break the other data?