close

How To read data from google drive Using Google Colab?

In This Tutorial, we are going to learn How To read data from google drive Using Google Colab? Manytimes we need to read data from our Google Drive But How to read? So in this tutorial, we are going to learn all possible ways to read data from google drive. Let’s get started with this tutorial.

How To read data from google drive Using Google Colab?

  1. How To read data from google drive Using Google Colab?

    To read data from google drive Using Google Colab First Of all Import Drive from the Google Colab Just Like this: from google.colab import drive And then mount your google drive with a path just like this: drive.mount(‘/content/drive’) The above code will prompt authorization. and then Put Your Path Here: %cd /content/drive/My Drive/Colab Notebooks/ And then After You read csv files with this code: df = pd.read_csv(“data_example.csv”) Now, You can easily read data from Google Drive. Thanks.

  2. read data from google drive Using Google Colab

    To read data from google drive Using Google Colab First Of all Import Drive from the Google Colab Just Like this: from google.colab import drive And then mount your google drive with a path just like this: drive.mount(‘/content/drive’) The above code will prompt authorization. and then Put Your Path Here: %cd /content/drive/My Drive/Colab Notebooks/ And then After You read csv files with this code: df = pd.read_csv(“data_example.csv”) Now, You can easily read data from Google Drive. Thanks.

Method 1: Use this Example

First Of all Import Drive from the Google Colab Just Like this.

from google.colab import drive

And then mount your google drive with a path just like this.

drive.mount('/content/drive')

The above code will prompt authorization. and then Put Your Path Here.

%cd /content/drive/My Drive/Colab Notebooks/

And then After You read csv files with this code

df = pd.read_csv("data_example.csv")

Now, You can easily read data from Google Drive. Thanks.

Method 2: Use this Example.

You can use this example.

import glob
from google.colab import drive
drive.mount('/gdrive', force_remount=True)

#!ls "/gdrive/My Drive/folder"

files = glob.glob(f"/gdrive/My Drive/My Data/*.pdf")
for file in files:  
  do_something(file)

Conclusion

It’s all About this article. Hope this method worked for you. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?

Also, Read

Leave a Comment