Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the file path for a file in google drive for use in colab?

I need the file path for a file stored in Google drive, so I can access it from a Google colab notebook.

E.g.

my_dat = ZipFile('/content/drive/MyDrive/some/file/structure/dat.zip', 'r')

Is there a quick way to "copy as path" or otherwise get the file path to the clipboard as quickly as possible from google drive?

My current method is to manually type up the file path, which is very tedious when doing it repeatedly for files deep down in directories. Basically all I need is a way to quickly and easily have 'MyDrive/some/file/structure/dat.zip' on my clipboard (e.g. similar to here), just without manually typing it.

like image 265
stevec Avatar asked Oct 18 '25 23:10

stevec


1 Answers

I made my own library to make it easier.

!pip install kora
from kora.drive import get_path
p = get_path(file_id)
like image 97
korakot Avatar answered Oct 22 '25 04:10

korakot