kpfleming / jinjanator

Jinja2 Command-Line Tool, reworked, again
BSD 2-Clause "Simplified" License
68 stars 5 forks source link

Support tabular formats: jsonlines, csv #28

Open cmungall opened 7 months ago

cmungall commented 7 months ago

It would be handy to have direct support for jsonl and CSV/TSV formats.

The easy workaround is:

jq -s '{ "items": . }' my.jsonl jinjanate my.j2 --format json

(assuming my jinja2 iterates through a key items)

or

jq -s . my.jsonl jinjanate my.j2 --format json --format-option array-name=items

Similarly, for CSV/TSV input tools like csvjson can easily do the processing up-front

So low priority but would be handy to avoid boilerplate preprocessing

kpfleming commented 5 months ago

Definitely an interesting idea, and this sort of thing is the reason why plugin support was created :-)

If the preprocessing can be done by a Python package, then creating a plugin would be fairly easy to do.