File size: 607 Bytes
45bc22a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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')