'.ipynb Julia files to .jl files
Is there a convenient way to convert several .ipynb Julia files produced with Jupyter notebook to .jl working files?
It is good if the markdown written with Jupyter are kept but not mandatory for my usage.
Here is sample of what my files contain:
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Some useful functions required to build the model"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"distance (generic function with 1 method)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Euclidean distances between point p1 and p2\n",
"function distance(p1,p2)\n",
" dist=((p1[1]-p2[1])^2+(p1[2]-p2[2])^2)^(1/2)\n",
" return dist\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Tripletas (generic function with 1 method)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
Solution 1:[1]
You can also use the nbexport function from NBInclude.jl in Julia, e.g.
using NBInclude
nbexport("Notebook.jl", "Notebook.ipynb")
which also converts markdown cells into formatted and line-wrapped comments in Julia.
(Note that this package also allows you to use the notebook file directly from Julia, without conversion.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SGJ |
