Last active
August 16, 2021 08:19
-
-
Save sanjeed5/75a6f53419cc99abdb9fdc540b4fe848 to your computer and use it in GitHub Desktop.
How to download competition dataset from Kaggle to Google Collab easily and unzip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copy paste this gist in a Google Collab cell | |
| # Go to your Kaggle competition page -> data, scroll below to see the kaggle api command which looks similar to below line | |
| # !kaggle competitions download -c competitive-data-science-predict-future-sales -p data | |
| # Replace that line accordingly in the below code | |
| # Run the cell | |
| !pip install kaggle | |
| from google.colab import files | |
| files.upload() | |
| !echo -E "Upload your kaggle.json API credentials now" | |
| !echo -E "Check here to see how to download that: https://github.com/Kaggle/kaggle-api#api-credentials" | |
| !mkdir ~/.kaggle | |
| !cp kaggle.json ~/.kaggle/ | |
| !chmod 600 ~/.kaggle/kaggle.json | |
| !echo "Authentication done" | |
| # Replace below line accordingly | |
| !kaggle competitions download -c competitive-data-science-predict-future-sales -p data | |
| # "-p data" downloads it to data folder. | |
| echo "Data download to data directory" | |
| !ls data | |
| !echo "Unzipping all zip files" | |
| !unzip data/\*.zip -d data | |
| !ls data | |
| !echo "Removing zip files" | |
| !rm data/*.zip | |
| !ls data | |
| !echo "Files downloaded and unzipped in data directory" | |
| !echo "If this was helpful, comment or star to let me know here: https://gist.github.com/sanjeed5/75a6f53419cc99abdb9fdc540b4fe848" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment