Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

%load magic doesn't load file into cell

I am trying to use %load localfolder/something.txt in google colab and nothing shows up.

The same happens when I try to %load something from a remote location.

Note that when the file location does not exist, the magic command throws an error. When it exists it remains silent.

The magic command %load is listed in %lsmagic but doesn't seem to be doing its job.

I am looking for either (a) some magic trick to make %load load file content into my cell or (b) some other way of efficiently loading text into a colab cell.

Context: I am teaching a class. I would like to provide solutions to exercises via this mechanism. I am currently going with !cat on some local files

Here is an example: https://colab.research.google.com/github/eickenberg/bug-free-garbanzo/blob/master/Untitled.ipynb

Note that in the notebook the local file doesn't exist, but the remote one does. The local one could be obtained by cloning the repo. But that also doesn't work.

like image 480
eickenberg Avatar asked Jul 17 '26 13:07

eickenberg


1 Answers

This is https://github.com/googlecolab/colabtools/issues/42 (sorry, no clever workaround beyond what you already have with cat & copy/paste).

like image 161
Ami F Avatar answered Jul 19 '26 02:07

Ami F



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!