Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload my dataset into Google Colab?

I have my dataset on my local device. Is there any way to upload this dataset into google colab directly.

Note:

I tried this code :

from google.colab import files
uploaded = files.upload()

But it loads file by file. I want to upload the whole dataset directly

like image 854
mohamed_abdullah Avatar asked Nov 15 '25 10:11

mohamed_abdullah


2 Answers

Here's the workflow I used to upload a zip file and create a local data directory:

  1. zip the file locally. Something like: $zip -r data.zip data
  2. upload zip file of your data directory to colab using their (Google's) instructions.
from google.colab import files

uploaded = files.upload()
  1. Once zip file is uploaded, perform the following operations:
import zipfile
import io

zf = zipfile.ZipFile(io.BytesIO(uploaded['data.zip']), "r")
zf.extractall()

Your data directory should now be in colab's working directory under a 'data' directory.

like image 67
VdZ Avatar answered Nov 17 '25 09:11

VdZ


Zip or tar the files first, and then use tarfile or zipfile to unpack them.

like image 44
Craig Citro Avatar answered Nov 17 '25 09:11

Craig Citro