Datasets:
#!/usr/bin/env python3 | |
import os | |
import boto3 | |
import tarfile | |
from pathlib import Path | |
DATASET = 'kendex.tar.gz' | |
repo_root = Path(__file__).resolve().parent.parent | |
local_path = os.path.join(repo_root, 'data', DATASET) | |
if not Path(local_path).exists(): | |
s3 = boto3.resource('s3') | |
kendex = s3.Bucket('kendex') | |
kendex.download_file(DATASET, local_path) | |
print('downloaded') | |
expanded_path = os.path.join(repo_root, 'data', 'kendex') | |
if not Path(expanded_path).exists(): | |
file = tarfile.open(local_path) | |
file.extractall(expanded_path) | |
file.close() | |
print('untar\'d, gunzip\'d') | |