Coder Social home page Coder Social logo

py2ipynb's Introduction

py2ipynb

Converts a .py python source file to a V.4 .ipynb jupyter/ipython notebook.

Based on this and this posts. Question originally asked on stackoverflow.

(Forked from py2ipynb)

This fork aims to allow back in forth between an ipynb jupyter/ipython notebook and the exported .py file. We want to allow using source control and revision comments on the .py file and import back into a notebook as a deployment step.

Adaptations

  • Using pycharm style since it seems to correspond to the notebook export style
  • Make Python 3 friendly

Prerequisites

This script has been tested with Python 3.5.2. The versions of dependencies specified in the requirements.txt are based on the versions needed by jupyter 1.0.0. If you upgrade your jupyter installation, you might have to adjusts the requirements accordingly.

Usage

$ python3 py2ipynb.py from-notebook.py to-notebook.ipynb

Caveats

Unfortunately, the out-of-the-box Jupyter converter to .py does not deliminate Markdown cells, it just puts the Markdown in comments. Doing so, we don't know when a code cell ends and a Markdown cell begins. If we do want to restore Markdown properly, this suggests we should develop a custom exporter. The project is nbconvert. The current Jinja template file is python.tpl. The template and/or code must be modified to suit the Markdown cell marker like so:

##
# md
"""
# Header

* item 1
* item 2
"""

py2ipynb's People

Contributors

yianni avatar jeffheon avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.