download kaggle dataset in colab
xxxxxxxxxx
import os
# You can use my dummy account =)
os.environ['KAGGLE_USERNAME'] = "whydoihavetodothiseh"
os.environ['KAGGLE_KEY'] = "1c0534cf33c5d00bb380dc4aebadd907"
# Dataset link from "Copy API command" button at kaggle
!kaggle datasets download -d mathchi/churn-for-bank-customers
# unzip last downloaded zip
!unzip -o $(ls -hat | grep -m 1 ".zip")
# equivalent to
# !unzip -o churn-for-bank-customers.zip
import pandas as pd
churn = pd.read_csv("churn.csv")
churn.head()
xxxxxxxxxx
from google.colab import files
import os
#if you've already uploaded kaggle.json before, don't do it again
if not(os.path.exists("kaggle.json")):
files.upload() #upload kaggle.json
!pip install --upgrade --force-reinstall --no-deps kaggle
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!ls ~/.kaggle
!chmod 600 /root/.kaggle/kaggle.json
#COMPETITION DATASET
dataset_name="name of competition" #you can find this on the competition data page
!kaggle competitions download -c {dataset_name}
!mkdir {dataset_name}
!unzip -q {dataset_name}.zip -d {dataset_name}
!rm -f {dataset_name}.zip
#Public Dataset
dataset_url="NAME OF DATASET"
dataset_name=dataset_url.split("/")[1]
!kaggle datasets download -d {dataset_url}
!mkdir {dataset_name}
!unzip -q {dataset_name}.zip -d {dataset_name}
!rm -f {dataset_name}.zip
xxxxxxxxxx
Create api key
and yout colab:
from google.colab import files
files.upload() #upload kaggle.json
!pip install --upgrade --force-reinstall --no-deps kaggle
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!ls ~/.kaggle
!chmod 600 /root/.kaggle/kaggle.json
!kaggle competitions -h
!kaggle competitions download -c DATASET