1

Error when i want to use a file from driv in colab

from google.colab import drive
drive.mount('/content/drive')

and them

INPUT_DIRECTORY='/content/drive/My Drive/deepcumbia/data/xml'

error:

Could not find directory /content/drive/My/
  • See this [Google Colab: how to read data from my google drive?](https://stackoverflow.com/questions/48376580/google-colab-how-to-read-data-from-my-google-drive/53592023) – Yoshikage Kira Sep 17 '19 at 19:21

3 Answers3

4

Escape the space.

INPUT_DIRECTORY='/content/drive/My\ Drive/deepcumbia/data/xml'
Bob Smith
  • 36,107
  • 11
  • 98
  • 91
1

This is to add another way which worked for me, i.e. double check the actual directory path in colab.

When debugging this same issue, I noticed Google Colab takes the Google Drive default directory a bit different. E.g. in Google Colab, the directory looked like this, there is no space in the word "MyDrive":

enter image description here

But when I browsed to the Google Drive, noticed there is a space in "My Drive": enter image description here

So, for my case, I changed from:

sth= pd.read_csv('/content/drive/My Drive/Colab Notebooks/Datasets/xyz.csv', index_col='abc')

to

sth= pd.read_csv('/content/drive/MyDrive/Colab Notebooks/Datasets/xyz.csv', index_col='abc')

Then it worked.

MK 5012
  • 29
  • 1
  • 9
0

I have had similar issues before too. This problem comes up when there is space in the link or path.

Thus, here's the universal solution : add a \ before the space.

So, if it's dir = 'My Drive', change it to dir = 'My\ Drive'.

It will always work.

Moreover, here's the solution to your problem:

INPUT_DIRECTORY='/content/drive/My\ Drive/deepcumbia/data/xml'
Jay Gohil
  • 1
  • 1