Daniel Power
Daniel Power

Reputation: 645

Save html of a Jupyter notebook from within the notebook

My Jupyter workflow for exploratory analysis looks like:

  1. Fiddle with some parameters.
  2. Run the notebook; generate output.
  3. Eyeball outputs.
  4. Repeat.

Can anyone suggest a command to make the notebook to save a copy of itself (e.g as an html in the output folder), so that if I want to recreate a particular experiment (results from a particular parameter set) I can do so?

Upvotes: 4

Views: 3159

Answers (1)

CodingYourLife
CodingYourLife

Reputation: 8588

Yes you can. Just add a safe cell by using cell magic. After using nbconvert you can rename the file and append a date

%%bash
jupyter nbconvert --to html MyNotebookName.ipynb
mv MyNotebookName.html $(date +"%m_%d_%Y-%H%M%S")_MyNotebookName.html

Upvotes: 3

Related Questions