I am doing jupyter-nbconvert --to script mynb.ipynb
to get a .py
from my notebook. This gives me everything in the notebook. I was wondering if I can set nbconvert to save in the .py
script only the cells marked as initialization
in my notebook. I presume I need to make a template for that, but customizing if nbconvert reads not very well to me, especially for this case.
This is how the ipynb looks like. Can one use "init_cell": true
in the customization?
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-06T02:39:41.586987Z",
"start_time": "2018-07-06T02:39:41.412779Z"
},
"collapsed": true,
"tags": [
"ATaggedCell"
]
},
"outputs": [],
"source": [
"# this is tagged, but is not an initialization cell\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"init_cell": true
},
"outputs": [],
"source": [
"# this is not tagged, but is an initialization cell\n",
"import pandas as pd"
]
}
],