Limit CSV fields on export output
Needed for socface
Refs https://redmine.teklia.com/issues/3267
When building a CSV file using arkindex export csv
, we need a new option that allows to limit columns in the CSV.
This dev brings a new option named -f
or --field
that a user can specify multiple times to limit columns:
arkindex export path/to/db.sqlite csv --output test.csv -f id -f created -f entity_*
should only output the columns:
- id
- created
- all that start with
entity_
A user may specify a pattern to match multiple keys (this is required for generated column names like for metadata & entities): you should use the fnmatch.filter method as it supports everything we would ever need.
Please do not alter the CSV workflow, I do not need to dynamically disable any part of the csv generation: you just need to filter out what will be in the output.
Don't forget to document that in the public markdown documentation (especially the fnmatch.filter part !)