CrashingWater
CrashingWater

Reputation: 181

Import data from shared Google drive into Google Colaboratory

How can I view files that exist in a shared folder on Google Drive? I have tried:

from google.colab import drive
drive.mount("/content/gdrive")
os.listdir("/content/gdrive/My Drive/")

but I cannot see the folder that was shared with me. The folder was created by another person and I have edit abilities on the folder but am not the owner. In Google Drive the folder does not appear under the "My Drive" section but instead is under the "Shared with me" section. Is it still possible to access the contents in Colab?

Upvotes: 3

Views: 3893

Answers (2)

Prasad K
Prasad K

Reputation: 31

Right Click on the Shared Folder in Colab and Select option "Add shortcut to Drive"

Then proceed to your google colab workbook and type

from google.colab import drive

drive.mount('/content/drive')

Your drive gets mounted and you can trace your shared folder there. Locate your files and copy their file path and bring them to colab for exercises.

Upvotes: 0

CrashingWater
CrashingWater

Reputation: 181

Click on the folder and then click on an option that says "Add to My Drive." The shared folder should now be visible in Google Colab.

Upvotes: 2

Related Questions