Last active
March 7, 2018 21:14
-
-
Save act65/00ef8c51158d676c26eb10a0cecc1877 to your computer and use it in GitHub Desktop.
get datasets from kaggle using their api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import csv | |
import time | |
import argparse | |
import subprocess | |
def parse_args(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--search_terms", type=str) | |
return parser.parse_args() | |
def main(search_terms): | |
with open('/tmp/search_terms.csv', "w") as f: | |
subprocess.call(['kaggle', 'datasets', 'list', '-v', | |
'-s', search_terms], stdout=f) | |
with open('/tmp/search_terms.csv') as f: | |
reader = csv.reader(f) | |
names = [] | |
for i, row in enumerate(reader): | |
if i != 0: | |
names.append(row[0]) | |
print(names) | |
for name in names: | |
subprocess.call(['kaggle', 'datasets', 'download', '--dataset', name]) | |
if __name__ == '__main__': | |
args = parse_args() | |
main(args.search_terms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment