Skip to content Skip to sidebar Skip to footer

Loading Local Data Google Colab

I have a npy file, (largeFIle.npy) saved in the same 'colab notebooks' folder on my google drive that I have my google colab notebook saved in. I'm trying to load the data into my

Solution 1:

When you launch a new notebook on colab, it connects you with a remote machine for 12 hours and all you have there is the notebook and preloaded functions. To access your folders on drive, you need to connect the remote instance to your drive and authenticate it.

This thing bugged me for sometime when I was beginning too, so I'm creating a gist and I'll update it as I learn more. For your case, check out section 2 (Connecting with Drive). You don't have to edit or understand anything, just copy the cell and run it. It will run a bunch of functions and then give you an authentication link. You need to go to that link and sign-in with Google, you'll get an access token there. Put it back in the input box and press Enter. If it doesn't work or if there's some error, run the cell again.

In the next part I mount my drive to the folder '/drive'. So now, everything that's on your drive exists in this folder, including your notebook. Next, you can change your working directory. For me, I'm keeping all my notebooks in '/Colab' folder, edit it accordingly.

Hope it helps you. Feel free to suggest me edits to the gist as you learn more. :)

Solution 2:

Have you set up your google drive with google colab with this method. After mounting Google drive use below command for your problem (Assuming you have stored largeFIle.npy in Colab Notebook folder.)

dataset = np.load('drive/Colab Notebooks/largeFIle.npy, encoding='bytes')

Post a Comment for "Loading Local Data Google Colab"