0

I have mounted my google drive on to Colab and yet am unable to access a .csv file using Python. I've imported pandas here:

import pandas as pd

data = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/Capstone 3/country_vaccinations.csv')
print(data)

Also, if I try to open the file by double-clicking it directly, it says

"Error Could not fetch country_vaccinations.csv from backend"

Please let me know if you have any thoughts on this or could point me to a solution. Thanks!

Paul Brennan
  • 2,638
  • 4
  • 19
  • 26
  • 1
    Does this answer your question? [Colaboratory: Can I access to my Google drive folder and file?](https://stackoverflow.com/questions/47744131/colaboratory-can-i-access-to-my-google-drive-folder-and-file) – Paul Brennan Feb 16 '21 at 03:41

2 Answers2

0

To mount your Google drive to Colab:

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

and then to cd to any directory in the Google drive:

import os
os.chdir("drive/My Drive/<your-folder>")

and to list all items in the directory that Colab is working on (to make sure it's the right dir):

!ls
Tahil Bansal
  • 135
  • 6
0

Mount the Google drive into Colab:

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

You will have to paste the authorization token in the box provided.

Then copy the path of the csv file from the right hand navigator;

import pandas as pd
df = pd.read_csv(full_path)