1 from request_functions import *
9 parser = argparse.ArgumentParser(description='Output JSON of abstracts and bibliography of all articles passed in.')
10 parser.add_argument('-i', help='JSON file which includes eids')
11 parser.add_argument('--eid', '-e', help='Single eid')
12 parser.add_argument('-o', help='Where to append JSON results')
13 args = parser.parse_args()
18 with open(args.i, 'r') as f:
19 eids = [json.loads(line)['eid'] for line in f]
21 print('Need to either pass in an eid or a json file with eids')
23 # If the script gets interrupted, we need to start where we left off
26 with open(args.o, 'r') as f:
30 result = json.loads(line)
31 completed_eids.append(result['abstracts-retrieval-response']['coredata']['eid'])
38 print('{} completed eids'.format(len(completed_eids)))
39 with open(args.o, 'a') as out_file:
41 if eid not in completed_eids:
42 result = get_abstract(eid)
44 out_file.write(result)
50 with open('raw_data/missing_eids.json', 'a') as l:
51 # Add the bad lines from the output file
52 (l.write(e) for e in errors)
55 if __name__ == '__main__':