Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine file path in Google colab?

I mounted my drive using this : from google.colab import drive drive.mount('/content/drive/')

I have a file inside a folder that I want the path of how do I determine the path? Say the folder that contains the file is named 'x' inside my drive

like image 343
Tanmay Bhatnagar Avatar asked Nov 17 '18 20:11

Tanmay Bhatnagar


People also ask

How do I change the path of a file in Colab?

Click on “Choose Files” then select and upload the file. Wait for the file to be 100% uploaded. You should see the name of the file once Colab has uploaded it. Finally, type in the following code to import it into a dataframe (make sure the filename matches the name of the uploaded file).

What is the root directory of Google Colab?

Mounting Google Drive/content is the root folder of Google Colab and has to be appended to all paths used in the notebook.


2 Answers

The path will be /content/drive/My\ Drive/x/the_file.

like image 58
Bob Smith Avatar answered Nov 10 '22 10:11

Bob Smith


The path as parameter for a function will be /content/drive/My Drive/x/the_file, so without backslash inside My Drive

like image 7
MihneaAM Avatar answered Nov 10 '22 12:11

MihneaAM