Search code examples
google-colaboratory

import local file to google colab


I don't understand how colab works with directories, I created a notebook, and colab put it in /Google Drive/Colab Notebooks.

Now I need to import a file (data.py) where I have a bunch of functions I need. Intuition tells me to put the file in that same directory and import it with:

import data

but apparently that's not the way...

I also tried adding the directory to the set of paths but I am specifying the directory incorrectly..

Can anyone help with this?

Thanks in advance!


Solution

  • Now google is officially providing support for accessing and working with Gdrive at ease.

    You can use the below code to mount your drive to Colab:

    from google.colab import drive
    drive.mount('/gdrive')
    %cd /gdrive/My\ Drive/{location you want to move}