Reputation: 52967
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
Upvotes: 7
Views: 6208
Reputation: 2870
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.
Upvotes: 1
Reputation: 1758
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.
Upvotes: 1