'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?



Solution 1:[1]

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.

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CrashingWater
Solution 2 Jeremy Caney