I just started with the development of an export plugin which will generate a CSV file.
I wanted a quite specific set of columns combined with the Ahnentafel numbering.
I have been able to get the plugin to work. I can export all ancestors of the main person and leverage the person filter to e.g. exclude living people.
I now would like to add a couple of settings to the export, but struggle to do so. Neither documentation nor fiddling with ChatGPT and Copilot got me anywhere. I just can’t get additional settings into the export options. All documentation and examples I found seem to work with reports only.
Can someone point me into the right direction?
My current code looks like this, but the options are never added nor do I see the debug log entry:
Your addon registers the CSV type which is likely already registered. Not having written an export addon, I am not sure if an override like that is allowed or not. Have you tried changing to a unique extension? Although since you said your addon works, I’m not sure if this would help at all. I’ll be watching this thread.
Thanks for your quick response and suggestion.
I just tried with “acsv” to have something that is most likely not yet registered, but the behaviour is still the same.
It does not seem as though multiple EXPORT plugins sharing the registered file type will pose any problem. It does not compete for exclusive ownership… like the IMPORT modules that need to do file type recognition to automate choosing the appropriate IMPORT plugin.
And you will have already passed the “Choose the output format” part of the export wizard and be into “Export options”… that is where the EXPORT plugin would offer interface the filtering and include/exclude (or other custom) options.
The built-in CSV export plugin sets export options. Perhaps this is the example code that you were looking for?
Regarding your Gramps Plugin Registration (.gpr.py) file
I would suggest you set the “status” to something other than STABLE (UNSTABLE, EXPERIMENTAL, BETA) during alpha and beta development stages. See the Register module (Sphinx) developer documentation for what choices are available.
Also, set a help_url in your registration. As an EXPORT module that isn’t published, it doesn’t seem useful at first blush. (Since the Export Wizard doesn’t have Help buttons and you won’t have a listing with an associated Wiki button in the Addon Manager until published.) But, the Help → Plugin Manager (the enhanced addon) will have both a listing and enable a Wiki button. And, as a bonus in developer mode, Plugin Manager Enhanced has GUI to open your plugin ‘.py’ file for quick edits/tweaks. (Kari @kku has a Reload Plugins developer plug-in to force re-registering plug-in during the tweaking cycle.)
set the URL and then uncomment one of these sample help_url lines
Are you certain that you want to do this as an EXPORT plugin?
Without looking at your module, I’m assuming that the EXPORT wizard GUI puts a lot of annoying steps (without reassuring feedback) between you and your desired output. And if you get one thing wrong (like the custom filter), you’re back to step one.
This seems like a better candidate for a new (using the Simple Table from the Simple classes) tabular view mode and its Export View… especially since @SNoiraud added the (mostly hidden) feature to choose different delimiters… enabling a quick switch between CSV and TSV when commas embedded your exported data starts introducing parsing hassles. Or a table copy from a Quick View report plugin.
Or, if you want to side-step all the interface work entirely, SuperTool exposes easy access Download CSV and Copy buttons for outputting its Result table.
Thanks a lot for pointing me in the right direction!
I was not able to get the plugin running as Simple Table. After struggling for a while I took a closer look at the export csv example and that helped a lot!
I have working options for date and place format now, as I wanted and will continue to clean up the code and add some more options.
When it’s ready, I’ll share it here for anyone interested.
Thanks a lot!!
Another option that you might consider is a selectable numbering system, beyond just Ahnenatafel or a single style of presentation.
There are several reports that use a different numbering system… or offer choices. You can use their code as examples of implementation or numbering system choosers.
The Ahnentafel Report has code to do different stylings of that numbering system.
One of my (incomplete) pet projects was a breadcrumbed ancestor description following the National Genealogical Society Quarterly format. (I abandoned the project when the original AI coding prohibition was pronounced. But haven’t picked it back up since that restriction was relaxed.) It got as far as building and formatting the breadcrumb from an array of names. Hadn’t gotten to the point of populating the array using the Relationship Calculator methods with a Gramps tree.
A report might be another choice for this plug-in. CSV is viable as another document type.
That as well is a great idea.
Currently I only need the Ahnentafel numbering, as I’m researching together with my father in law who is unwilling to adopt Gramps (I tried really hard…) and keeps working with his Excel sheets and paper… So I needed to produce a csv file that matches his format for him top be able to compare and update his research.
To me, export sounds about right, as I’m exporting the data into the csv format.
I’m happy with the settings I can add now and will provide the plugin as soon as I’ve finalized the first version. As python is not my main programming language (it hurts, coming from Java… ) I’m always open to suggestions for improvements.
As I found it quite hard to adjust to python and the gramps api, I’ll stick with the current setup for now.
If this plugin becomes useful to others who might need more options, I’d be happy to extend it.