summaryrefslogtreecommitdiff
path: root/s2-papers.py
diff options
context:
space:
mode:
Diffstat (limited to 's2-papers.py')
-rw-r--r--s2-papers.py27
1 files changed, 1 insertions, 26 deletions
diff --git a/s2-papers.py b/s2-papers.py
index 7320c095..d5e8bcd4 100644
--- a/s2-papers.py
+++ b/s2-papers.py
@@ -8,6 +8,7 @@ import re
import json
import click
from s2 import SemanticScholarAPI
+from util import *
'''
s2 search API format:
@@ -59,31 +60,5 @@ def fetch_paper(paper_id):
time.sleep(random.randint(5, 10))
return paper
-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 read_json(fn):
- with open(fn, 'r') as json_file:
- return json.load(json_file)
-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_papers()