iodide-project / iodide

Literate scientific computing and communication for the web
Mozilla Public License 2.0
1.49k stars 141 forks source link

"export data" helper #627

Open hamilton opened 6 years ago

hamilton commented 6 years ago

Some Jupyter users (and I've been in this camp) will write a notebook simply to transform data and export it so they can use the data in some other system. It might be nice to provide some simple API functionality to export your data as a csv or json efficiently, so a user doesn't necessarily need to figure out how to do that w/ lower level system calls. The calls could look like:

iodide.file.exportAsCSV(data, 'out.csv')
iodide.file.exportAsJSON(data, 'out.json')
iodide.file.exportAsBinary(data, 'out.whatever')
// the functions above serve as convenience functions for this one:
iodide.file.export(data, Array.isArray(data) ? : 'csv' : 'json', 'out.data')
iodide.file.export(imgData, 'binary', 'out.imgData')

Or something like that.

bcolloran commented 6 years ago

:+1: good idea.

one wrinkle is that this will necessarily pop a download dialog when running in the browser (which might be weird during e.g. run all), so for people that don't want that directly in their code, we could also expose this functionality via point and click in the declared vars pane (click to download)