Overview
The repository includes two main scripts for programmatic data access:download_datasets.py- Downloads F1 datasets from Kaggle and creates consolidated archivesupload_to_hf.py- Uploads datasets to HuggingFace Hub (for maintainers)
Prerequisites
Install Required Libraries
Install the necessary Python packages:
kagglehub is required for downloading from Kaggle, while huggingface-hub is needed for HuggingFace uploads.Set Up Kaggle API Credentials
To download datasets from Kaggle, you need API credentials:
- Go to your Kaggle account settings
- Scroll to the “API” section
- Click “Create New Token” to download
kaggle.json - Place the file in
~/.kaggle/kaggle.json(Linux/Mac) orC:\Users\<Windows-username>\.kaggle\kaggle.json(Windows)
Using download_datasets.py
Thedownload_datasets.py script automates the process of downloading Formula 1 datasets from Kaggle.
Basic Usage
How It Works
The script performs the following operations:Download from Kaggle
Downloads the latest versions of two Kaggle datasets:
jtrotman/formula-1-race-datajtrotman/formula-1-race-events
Script Source Code
Here’s the core functionality fromdownload_datasets.py:
Custom Integration
You can integrate the download functionality into your own Python projects:Example: Custom Download Script
custom_download.py
Example: Selective Download
selective_download.py
Automated Updates
The RaceData repository uses GitHub Actions to automatically update the dataset within 3 hours after each race. You can implement similar automation:Example: Scheduled Updates with Cron
scheduled_update.py
Upload to HuggingFace (Maintainers)
For maintainers who want to upload data to HuggingFace, use theupload_to_hf.py script:
Setup
Upload Function
Fromupload_to_hf.py:
Troubleshooting
Kaggle API credentials not found
Kaggle API credentials not found
Ensure your
kaggle.json file is in the correct location:Dataset download fails
Dataset download fails
If the download fails, try:
- Verify your Kaggle API credentials are valid
- Check your internet connection
- Ensure you’ve accepted the dataset license on Kaggle’s website
- Update
kagglehubto the latest version:pip install --upgrade kagglehub
Permission denied errors
Permission denied errors
Make sure you have write permissions to the output directory:
Next Steps
Direct Download
Download the dataset as a zip file
HuggingFace Access
Use HuggingFace Datasets library
Quick Start
Start analyzing F1 data in minutes
Data Schema
Learn about the data structure
