How to Download Kaggle data set into Google drive using google Colab
First of all why we need to copy Kaggle data into colab or google drive?
kaggle only gives us 4GB disk space to write the data but when your data set is zipped you get a hard time. but google colab offers near 76GB space and we can expand it with mounting the google drive. By the way you can have a more flexible working environment.
let’s mount the Google driver first
There are two ways to mount Google Drive with Colabs. you can simply click the folder icon on the left side of the window and open the side menu, then click the mount icon shown below.
or just run this code
from google.colab import drivedrive.mount(‘/content/drive’)
Now we have to get API Token from Kaggle
Go “My Account” and scroll down to the API section. Click the “Create New API Token”
Then the Kaggle.json fill well be downloaded
Now is time to work with Jupiter notebook
first, we need to install Kaggle API
! pip install -q kaggle
now upload the Kaggle.json file
from google.colab import filesfiles.upload()
Let’s create a separate folder for it copy it
%%shell
mkdir /content/kagglecp kaggle.json /content/kaggle/
Change the permissions of the file.
! chmod 600 /content/kaggle/kaggle.json
now copy the below-shown code that kaggle given for your dataset
paste and run it.
! kaggle competitions download -c diabetic-retinopathy-detection -p ‘/content/drive/My Drive/targetFolder’
Use the unzip and rm command for Unzip files
#unzipping the zip files and deleting the zip files
!unzip \*.zip && rm *.zip
Happy Learning 😃….