top of page
Writer's pictureInfiLearn Academy

How to upload folder in Google Colab?

Updated: May 30, 2024

In this tutorial we have discussed two ways to upload folder or a dataset in Google Colab

  1. Upload to Session Storage

  2. Upload to Google Drive and Mount Google Drive to Google Colab


You can watch the step by step YouTube tutorial or follow the below steps.



1. Upload to Session Storage

This is the simplest method of adding datasets or folders in Google Colab. The only cons for this method is that the data will only be available for the current runtime. Once the runtime is terminated, all the dataset will be lost. This method is particularly useful for quick analysis, as we can simply upload the dataset and perform our analysis.


Let's have a look at the steps of adding data to session storage

Step 1: Connect the Google Colab notebook to runtime in order to enable file browsing

Step 2: Expand files from the left bar and select "Upload to Session Storage"


Using the left most button "Upload to Session Storage" you can simply upload the files or folders from your PC/ Laptop.

Step 3: Simply right click on the file / folder and select "copy path" in order to get the path where the files are saved. Later you can use this path for use in your Google Colab Code

Step 4: Make sure that the files are saved elsewhere, other the files will be lost once the runtime is terminated


2. Mount Google Drive

Using this method we can permanently store the dataset or folders in the Google Drive and we can connect our drive to the Colab Notebook. This way we can keep our dataset connected with the Colab notebook even if the runtime is terminated or if we reopen our notebook.

Let's have a look at the steps of adding data using Google Drive

Step1: Connect the Google Colab Notebook to a runtime in order to enable file browsing

Step2: Expand files from the left bar and select and "Mount Drive"


Using the button "Mount Drive" you can your Colab notebook to Google Drive where you can browse to your files/ folders

Step 3: Browse to the file/ folder which you want to use in your notebook and right click on the file/ folder and select "copy path" in order the get the path where the files are saved. Step 4: Now you can use this path for use in your Google Colab code


Using any of these two ways you can upload your dataset to the Google Colab notebook depending on your requirements.

28 views0 comments

Comments


bottom of page