Skip to content

Instantly share code, notes, and snippets.

@Mukei
Created March 17, 2019 14:41
Show Gist options
  • Save Mukei/05c0ca1317d3926c070318ff2f1973f0 to your computer and use it in GitHub Desktop.
Save Mukei/05c0ca1317d3926c070318ff2f1973f0 to your computer and use it in GitHub Desktop.
Some Python command to use Kaggle on Colab
# To access kaggle datasets
!pip install kaggle
# Import data from Kaggle
# Colab's file access feature
from google.colab import files
# Retrieve uploaded file
uploaded = files.upload()
# Print results
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
# Then move kaggle.json into the folder where the API expects to find it.
!mkdir -p ~/.kaggle/ && mv kaggle.json ~/.kaggle/ && chmod 600 ~/.kaggle/kaggle.json
# List kaggle project
!kaggle competitions list
#donwload earthquake data (for example...
!kaggle competitions download -c LANL-Earthquake-Prediction
#unzip training data for usage
!ls
!unzip train.csv.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment