diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-11-03 01:13:49 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-11-03 01:13:49 +0100 |
| commit | c2f4665dbe5ff1225f90afbaf590975057dc5026 (patch) | |
| tree | 48109101798b42018540deff7ac6873a067c937e /s2-search.py | |
| parent | 683a20d4d29958132fd49ddaeebf3d4f672085b7 (diff) | |
s2 dump scripts...
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() |
