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
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
def pull_kaggle_data(username,key):
import json
! mkdir .kaggle
token = {"username":username,"key":username}
with open(".kaggle/kaggle.json", "w") as file:
json.dump(token, file)
! cp .kaggle/kaggle.json ~/.kaggle/kaggle.json
================================================================================
pull_kaggle_data(username,key)
! kaggle competitions download -c malware-classification
import opendatasets as od
import pandas
od.download(
"https://www.kaggle.com/datasets/
muratkokludataset/acoustic-extinguisher-fire-dataset")