Skip to content

Instantly share code, notes, and snippets.

@Vaidic
Last active February 17, 2021 17:51
Show Gist options
  • Select an option

  • Save Vaidic/5aafd90b9fc2acfa42a20deee636a2c8 to your computer and use it in GitHub Desktop.

Select an option

Save Vaidic/5aafd90b9fc2acfa42a20deee636a2c8 to your computer and use it in GitHub Desktop.
!pip uninstall kaggle -y && pip install kaggle
import json
import zipfile
import os
api_token = {"username":"USERNAME","key":"KEY"}
!mkdir /root/.kaggle
with open('/root/.kaggle/kaggle.json', 'w') as file:
json.dump(api_token, file)
!chmod 600 /root/.kaggle/kaggle.json
!kaggle config set -n path -v/content
!kaggle config view
dataset = 'titanic' # change this to the dataset to download
os.environ['dataset']=dataset
!echo $dataset
!kaggle competitions download -c $dataset
!ls /content/competitions/$dataset
os.chdir('/content/competitions/'+dataset)
for file in os.listdir():
zip_ref = zipfile.ZipFile(file, 'r')
zip_ref.extractall()
zip_ref.close()
os.listdir()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment