Reputation: 370
I am working in Google Colaboratory. Until about a week ago, I was able to mount my shared drive using the following:
from google.colab import drive
drive.mount('/content/drive/')
and then read a data file using:
data = pd.read_csv('/content/drive/Team Drives/TestProject/test.csv')
About a week ago, after they updated team drives to shared drives, that stopped working. How do I access my shared drive files now?
Upvotes: 8
Views: 14077
Reputation: 182
This is the only simple solution that I found myself and is working like charm:
from google.colab import drive
drive.mount("/content/drive")
a) Writing Data to shared drive
!cp "//content/drive/Shareddrives/<shared_ drive_name>/my-video.mp4" "my-video.mp4"
b) Reading data from Shared Drive
!cat /content/drive/Shareddrives/<shared_ drive_name>/example.txt
#or
pd.read_csv("/content/drive/Shareddrives/<shared_ drive_name>/data_example.csv")
Note: If if it did not work try to changing name of share drive without spaces
Upvotes: 0
Reputation: 78439
As of 2022, it looks like the Shared Drive path is Shareddrives
with no space. So:
drive.mount('/content/drive/')
# /contents/drive/Shareddrive/Foo is now pointing to my Foo shared drive
Upvotes: 1
Reputation: 370
All that needed to be done was update "Team Drives" to "Shared drives".
Changing the code to this works:
data = pd.read_csv('/content/drive/Shared drives/TestProject/test.csv')
Upvotes: 4