summaryrefslogtreecommitdiff
path: root/fetch-entries.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-10-31 01:42:14 +0100
committerJules Laplace <julescarbon@gmail.com>2018-10-31 01:42:14 +0100
commit26b8d0f08078b6356cdb815aa20ae3154ffe7665 (patch)
treee5c7d9031bc44e908598f2b7cc2a0b9989520848 /fetch-entries.py
parenta7f1d363eaef9149e54e5846072e710713cca7a7 (diff)
fetch entries
Diffstat (limited to 'fetch-entries.py')
-rw-r--r--fetch-entries.py47
1 files changed, 29 insertions, 18 deletions
diff --git a/fetch-entries.py b/fetch-entries.py
index b8279a1a..027b2955 100644
--- a/fetch-entries.py
+++ b/fetch-entries.py
@@ -3,23 +3,34 @@ import sys
import csv
import subprocess
-with open('./datasets/citations.csv', 'r') as f:
- reader = csv.reader(f)
- lines = list(reader)
- keys = lines[0]
- lines = lines[1:]
+import click
-print([line[1] for line in lines])
+@click.command()
+@click.option('--index', '-n', default=1, help='Index of CSV.')
+def fetch_entries(index):
+ keys, lines = read_citation_list(index)
-for line in lines:
- label = line[0]
- title = line[1]
- entries_fn = './datasets/scholar/entries/{}.csv'.format(title)
- print(entries_fn)
- if not os.path.exists(entries_fn):
- with open(entries_fn, 'w') as f:
- subprocess.call([
- './vendor/scholar.py',
- '-t', '-s', title, '--csv',
- ], stdout=f)
- sys.exit(1)
+ for line in lines:
+ label = line[0]
+ title = line[1]
+ entries_fn = './datasets/scholar/entries/{}.csv'.format(title)
+ print(entries_fn)
+ if not os.path.exists(entries_fn):
+ with open(entries_fn, 'w') as f:
+ subprocess.call([
+ './vendor/scholar.py',
+ '-t', '-s', title, '--csv',
+ ], stdout=f)
+ sys.exit(1)
+
+
+def read_citation_list(index):
+ filename = './datasets/citations.csv'
+ fn, ext = os.path.splitext(filename)
+ in_fn = fn + '-' + str(index) + ext
+ with open(in_fn, 'r') as f:
+ reader = csv.reader(f)
+ lines = list(reader)
+ keys = lines[0]
+ lines = lines[1:]
+ return keys, lines