jupyterlab_table
jupyterlab_table copied to clipboard
Add a download (as csv) button
I think this would be a very valuable addition!
Hey @dhirschfeld! Thanks for the feedback. I did some tinkering and jsontableschema-js (which this extensions already depends on for schema inference) happens to have a save to CSV feature. I created a gist to demonstrate: https://gist.github.com/gnestor/9044bfcc58b0a46c40977c815a0b756c.
I don't want to add any custom UI to this extension yet. It's first-and-foremost a mimerender extension for the application/vnd.dataresource+json
mime type. It works with Pandas DataFrames, CSV, JSON, etc. It's also kernel-agnostic. So the first priority is to optimize performance so that it's on par with Panda's static HTML tables. Then I'd like to explore features like this one and https://github.com/gnestor/jupyterlab_table/issues/3.
In the meantime, you can use either jsontableschema-js, jsontableschema-py, or some other library to save data to CSV.
Thanks for the example @gnestor - it very useful for a JS noob like me!
I'm putting some cycles into this and jupyterlab_vega today (see https://github.com/altair-viz/jupyterlab_vega/issues/24), so I might be able to add something similar to jupyterlab_table.
@dhirschfeld I forgot to mention that the simplest way to do this is simply df.to_csv('PATH_TO_FILE')
, which will write the CSV data to a CSV file. 👍
Indeed, that's straightforward for an analyst/developer but a button with a popup save-file dialog is quite convenient and probably more noob-friendly.
I can imagine that if the table display is part of a dashboard the end-user may not have programmatic access to the kernel to run such a command. Also, a remote kernel won't have access to the local machine to save the file to unlike a JS/client side solution.
I like your dashboard use case 👍