timvink / mkdocs-table-reader-plugin

MkDocs plugin that enables a markdown tag like {{ read_csv('table.csv') }} to directly insert various table formats into a page
https://timvink.github.io/mkdocs-table-reader-plugin/
MIT License
111 stars 18 forks source link

Add `.query()` for post-processing #44

Closed timvink closed 1 year ago

timvink commented 1 year ago

Being able to do something like:

{{ read_csv('path_to_table.csv').query('population < 10000') }}

Might simplify a setup considerably.

I'm not sure if it's a good design choice though. You could use a hook to preprocess tables also (see preprocessing tables using hooks), which is probably a better design pattern (because then you don't have any data logic inside your documentation code, it's just input/output).

If you read this & have a use-case for this, let me know!

roaldarbol commented 1 year ago

Hi again Tim. Whilst I agree that hooks have their use-cases, for the vast majority of tables to be used in documentation, they will not be needing major pre-processing. The needed functionality would be to query a "database"/file and select/filter/sort. Having a separate hook for each table you will need is overkill - for me at least. The difference from page to page will be .query('x=="A"'), .query('x=="B"'), etc. However, I do think #45 will provide a better solution if you manage to implement that as it is more Markdownian (if we can coin that term). :-)

timvink commented 1 year ago

as it is more Markdownian (if we can coin that term). :-)

Haha, good one! I see what you mean, I agree #45 is a better fit, and easier to implement. I also don't want to implement the same functionality twice, so closing this one.