Skip to content

Instantly share code, notes, and snippets.

@amitness
Created December 18, 2019 08:23
Show Gist options
  • Save amitness/3d0a9137300a66ee7ce471c576a772f0 to your computer and use it in GitHub Desktop.
Save amitness/3d0a9137300a66ee7ce471c576a772f0 to your computer and use it in GitHub Desktop.
Create a jupyter notebook programatically in python
from nbformat.v4 import new_notebook, new_code_cell, new_markdown_cell

import nbformat

nb = new_notebook()

nb.cells = [
    new_code_cell('print("hello")'),
    new_markdown_cell('# Cool')
]

nbformat.write(nb, 'test.ipynb')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment