[5a7589]: / notebooks / nbtopython

Download this file

8 lines (6 with data), 205 Bytes

set -e
infile=$1
jupyter-nbconvert --to python $infile
pyfile="${infile%.ipynb}.py"

cat $pyfile | sed '/^$/N;/^\n$/D' | sed "s/^# In\[[ 0-9]*\]:/#cell#/"  > "${pyfile}.tmp"
mv "${pyfile}.tmp" "${pyfile}"