jupyterlab_table icon indicating copy to clipboard operation
jupyterlab_table copied to clipboard

Add a download (as csv) button

Open dhirschfeld opened this issue 8 years ago • 6 comments

I think this would be a very valuable addition!

dhirschfeld avatar Jan 20 '17 05:01 dhirschfeld

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.

gnestor avatar Feb 11 '17 07:02 gnestor

Thanks for the example @gnestor - it very useful for a JS noob like me!

dhirschfeld avatar Mar 05 '17 22:03 dhirschfeld

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.

gnestor avatar Mar 05 '17 22:03 gnestor

@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. 👍

gnestor avatar Mar 05 '17 23:03 gnestor

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.

dhirschfeld avatar Mar 05 '17 23:03 dhirschfeld

I like your dashboard use case 👍

gnestor avatar Mar 06 '17 00:03 gnestor