0

I want to create a function to read files from the folder one by one in the colab. I have tried below that i.e. I uploaded my folder into My Drive and then tried to access it from there. But still, it is showing the error.

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

mypath = "/gdrive/My Drive/resume pdf" #enter your path here where you saved the resumes
onlyfiles = [os.path.join(mypath, f) for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f))]

Error-->

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-15-a7a8abc74cc6> in <module>()
      1 mypath = "/gdrive/My Drive/resume pdf" #enter your path here where you saved the resumes
----> 2 onlyfiles = [os.path.join(mypath, f) for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f))]

FileNotFoundError: [Errno 2] No such file or directory: '/gdrive/My Drive/resume pdf'`enter code here`

I have crossed check that there is a folder named "resume pdf" in my drive. So How can I upload a local folder and access each file of it one by one in colab??

Mukul Kumar
  • 564
  • 1
  • 5
  • 24

1 Answers1

1

You mounted it at /content/gdrive, but you try to access it at /gdrive, that's the error.

Just change to

mypath = "/content/gdrive/My Drive/resume pdf"
korakot
  • 37,818
  • 16
  • 123
  • 144