holzschu / Carnets

Carnets is a stand-alone Jupyter notebook server and client. Edit your notebooks on the go, even where there is no network.
https://holzschu.github.io/Carnets_Jupyter/
BSD 3-Clause "New" or "Revised" License
566 stars 32 forks source link

How to import ipynb from URL? #142

Closed n8henrie closed 3 years ago

n8henrie commented 3 years ago

Hi all, thanks for a really interesting project.

Today I went bonkers trying to load https://raw.githubusercontent.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/01-g-h-filter.ipynb into Carnets. Does anyone have a good strategy for loading ipynb files from the web?

I eventually figured out that I could !curl $URL > file.ipynb, but prior to that spend a fair amount of time trying !wget, %run, %load, and iOS Shortcuts (which kept renaming it foo.ipynb.txt no matter what I tried).

Is there a more obvious way to do this that I missed?

EDIT: I think the -O (--remote-name) option is probably the easiest bet:

!curl -O https://raw.githubusercontent.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python/master/01-g-h-filter.ipynb
holzschu commented 3 years ago

Hi, for that specific case, I would go with "clone the repository using the WorkingCopy app", then work in the repository folder using Carnets (and Carnets "openFolder" feature on the repository directory).

You can also use the "Download Zip" feature from https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python, then uncompress the Zip and work inside the downloaded directory.

nlg35 commented 3 years ago

Hi, For persons looking for a downloading code, may I suggest this :

If you can download a notebook (or any file) by internet to Carnets, you can do it by python code.

First in a cell of Carnets, install the library : !pip install requests

Then in another cell of Carnets :

url = "https://your_path/filename.ipynb"
r = requests.get(url, allow_redirects=True)
open('filename.ipynb', 'wb').write(r.content)

The file is downloaded to your current directory (in Carnets). And then, you can open it.

I tried with a heavy notebook containing plenty of embed pictures, it worked very well.

Hope it can help. NLG