diff options
Diffstat (limited to 's2-search.py')
| -rw-r--r-- | s2-search.py | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/s2-search.py b/s2-search.py index 1804207b..b9e8db2d 100644 --- a/s2-search.py +++ b/s2-search.py @@ -5,9 +5,10 @@ import subprocess import time import random import re -import json +import simplejson as json import click from s2 import SemanticScholarAPI +from util import * ''' s2 search API format: @@ -41,28 +42,5 @@ def fetch_entries(index): write_json(entry_fn, results['results'][0]) time.sleep(random.randint(10, 20)) -def read_citation_list(index=0): - filename = './datasets/citations.csv' - if index > 0: - fn, ext = os.path.splitext(filename) - filename = fn + '-' + str(index) + ext - with open(filename, 'r') as f: - reader = csv.reader(f) - lines = list(reader) - keys = lines[0] - lines = lines[1:] - return keys, lines - -def write_json(fn, data): - with open(fn, 'w') as outfile: - json.dump(data, outfile) -def write_csv(fn, keys, rows): - with open(fn, 'w') as f: - writer = csv.writer(f) - if keys is not None: - writer.writerow(keys) - for row in rows: - writer.writerow(row) - if __name__ == '__main__': fetch_entries() |
