moctarjallo
moctarjallo

Reputation: 1615

How to share my google colaboratory along with data from mounted drive?

I am working on google colaboratory and i have mounted my gdrive to it so i can access the csv data i am processing with pandas for example.

# Mount the path to the location of your data
from google.colab import drive
drive.mount('/gdrive')

Everything works great.

But now when i share my colab to other colleagues they have no access to the csv files ofcourse. So how can i share these csv residing in my drive as well ? Or are there other alternatives to hosting the data into gdrive so i and my colleagues can access them through a panda read_csv ?

Upvotes: 3

Views: 2521

Answers (1)

korakot
korakot

Reputation: 40828

There are 2 easy ways.

1. gdown

If you have just 1-2 csv files that can be shared publicly. You can get the file IDs. Then, use gdown to download it (no authentication).

Get ID from the shared link

https://drive.google.com/file/d/1KgSEm4A7hCov2Ta6-CZldqT-9JgtiVRI/view?usp=sharing

!gdown --id 1KgSEm4A7hCov2Ta6-CZldqT-9JgtiVRI

Your friend will get dataset.zip in the current directory.

2. kora.drive

If you have many csv files/folders, just put them all in a single folder and share that folder to your friend. I made a library to help download the whole folder. It will check user permission to read that folder, by asking you to authenticate.

Get Folder ID from the folder link

https://drive.google.com/drive/folders/1HvIeNhqtFVllXFWzH5NawDdnIfgGDwCK

!pip install kora -q
from kora import drive

drive.download_folder("1HvIeNhqtFVllXFWzH5NawDdnIfgGDwCK")

Your friend will get a new directory Dataset inside current directory (e.g. /content/) with all files/subfolders copied from your google drive.

Upvotes: 3

Related Questions