I am able to mount Google drive using the code below:
from google.colab import drive drive.mount('/content/drive')
But the above mounts the Root folder enabling all file access within the drive.
I want a particular folder in Google drive to to be mounted (for example just the dataset folder). How can I achieve that?
If you want to change directory from google colab into google drive, connect to google drive first. Change to the google drive directory. Yes, because this answer is slightly outdated. Now the same path should be: '/content/drive/MyDrive/'.
Instructions. Place the Jupyter notebook in your Google Drive. In Google Drive in your web browser, open the Jupyter notebook with Colaboratory. Run the cells in this notebook to mount the drive and practice reading & writing files.
Access local files through the file-explorer You can either use the upload option at the top of the file-explorer pane to upload any file(s) from your local file system to Colab in the present working directory. 2. Select the “upload” option.
It's not possible to mount a subfolder, only top-level Drive. You can mount Drive in some out-of-the-way place and then symlink the folder you want someplace more central, e.g.:
from google.colab import drive drive.mount('/gdrive') !ln -s "/gdrive/My Drive/theFolder" "/content/theFolder"
If you have confidential files, you can create a new google login for collab studies, at least until google creates a way to mount the folder and not the entire driver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With