connect google drive to colab

To connect Google Drive to Google Colab, follow these steps:

  1. Open Google Colab: Go to colab.research.google.com and sign in to your Google account.

  2. Create a new notebook: Click on "New Python 3 Notebook" to create a new notebook.

  3. Mount Google Drive: Use the following code snippet to mount Google Drive to your Colab notebook:

from google.colab import drive
drive.mount('/content/drive')
  1. Authenticate and authorize access to Google Drive: When you run the code snippet, a link will appear. Click on the link, select your Google account, and grant permissions to access your Google Drive.

  2. Copy the authorization code: After granting permissions, you will receive an authorization code. Copy the code and paste it into the Colab notebook.

  3. Verify the connection: To verify if the connection is successful, run the following code snippet:

!ls '/content/drive/My Drive'

This will display the contents of your Google Drive.

That's it! You have successfully connected Google Drive to Google Colab. Now you can access and manipulate files stored in your Google Drive directly from your Colab notebook.