Skip to content

Instantly share code, notes, and snippets.

@santiagobasulto
Created August 28, 2025 19:32
Show Gist options
  • Save santiagobasulto/f77202cbfdc53ed143ab59206a6a50cd to your computer and use it in GitHub Desktop.
Save santiagobasulto/f77202cbfdc53ed143ab59206a6a50cd to your computer and use it in GitHub Desktop.

1. Create the project with internet access

This will allow you to download datasets directly. image

2. Provide your Kaggle credentials

WARNING! You must remove these before publishing the project. image

3. Download the dataset!

I prefer to use kagglehub, with a very simple script (referenced below).

import os
import json

with open("kaggle.json") as fp:
    credentials = json.load(fp)

username = credentials['username']
key = credentials['key']
# alternatively, ask for key
# username = input("Enter your username: ")
# key = input("Enter your key: ")

# This sets the keys
os.environ['KAGGLE_USERNAME'] = username
os.environ['KAGGLE_KEY'] = key
 
from kaggle import api

api.dataset_download_files('yasserh/titanic-dataset', path='data', unzip=True)

4. Execute the script

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment