7

It would be really handy to have a button to copy raw code from a Jupyter notebook to the clipboard so it can be dumped into a text file, .py/.R script, or straight into the terminal (a button like github has to copy to clipboard)

Does a button (or even a chrome add on) exist?

Obviously you could copy/paste sections manually into a txt file, but that's laborious for long notebooks/markdowns

2
  • 1
    How about file > download?
    – Xantium
    Mar 24, 2018 at 1:07
  • try import nbformat.v4 its the library of jupyter, i did similar stuff some time ago here it won't be hard to filp it.
    – rho
    Mar 24, 2018 at 1:07

3 Answers 3

4

Yes,there is a button:

File > Download as > Python (.py)

1

There is a more handy way for Mac OS users.

By installing an Automator script converting the ipynb file to py first, then automatically copy the content to the clipboard with one right-click and select the script in the Quick Action part.

Github link

enter image description here

1

You can use the magic command %%writefile to save as py file

%%writefile "directory/to/file/filename.py"

However, you should place this command at the top of the cell, otherwise it will throw an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.