Easily Import Kaggle Datasets in Google Colab with Python

Original article was published by Joseph Lilleberg on Deep Learning on Medium


Finally, the function will download and upzip the contents of the Kaggle dataset.

# Download and unzip Kaggle Dataset
print('Downloading Kaggle Dataset...')
dataset = '/'.join(dataset_url.split('/')[3:])
subprocess.run(["kaggle", "datasets", "download", "-d", dataset, "-p", "/content"])dataset = dataset.split('/')[-1]
with zipfile.ZipFile("{}.zip".format(dataset)) as zip_ref:
zip_ref.extractall("/content")

Put together, the entire script is as follows:

I hope this post has helped you better understand how to install Kaggle datasets in Google Colab. If you encounter any issues with this code, wording in the post, or have any other inquires, please don’t hestiate to let me know. Thank you!