-
Notifications
You must be signed in to change notification settings - Fork 20
/
author_list.py
108 lines (82 loc) · 3.36 KB
/
author_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Author: Michael Coughlin :)
import csv
import os
import numpy as np
import sys
import argparse
import argparse
import importlib
# Define the command-line argument parser
parser = argparse.ArgumentParser(description='Author List')
parser.add_argument('--list', help='Specify the list to import', required=True)
args = parser.parse_args()
# Import the specified list dynamically
list_module = importlib.import_module(args.list)
authors = list_module.authors
institution_list_ordered = []
for author in authors:
institutions = author["affiliations"]
for institution in institutions:
if institution in institution_list_ordered: continue
institution_list_ordered.append(institution)
print('--------')
print(f"Total {len(authors)} authors")
mnras_style = True
nature_style = False
spie_style = False
if mnras_style:
author_list = []
for ii, author in enumerate(authors):
author_institutions = author["affiliations"]
indices = []
for author_institution in author_institutions:
indices.append(institution_list_ordered.index(author_institution))
author_list.append('%s$^{%s}$' % (author["name"], ",".join([str(x+1) for x in indices])))
if np.mod(ii, 4) == 0 and ii > 0:
author_list.append('\\newauthor')
print(", ".join(author_list))
institution_list = []
for ii, institution in enumerate(institution_list_ordered):
institution_list.append('$^{%s}$ %s' % (str(ii+1), institution))
print("\\\\ \n".join(institution_list))
print("--------")
institution_list = []
for ii, institution in enumerate(institution_list_ordered):
institution_list.append('\item %s' % (institution))
print("\n".join(institution_list))
if nature_style:
author_list = []
for author in authors:
author_institutions = author["affiliations"]
indices = []
for author_institution in author_institutions:
indices.append(institution_list_ordered.index(author_institution))
author_list.append('%s$^{%s}$' % (author["name"], ",".join([str(x+1) for x in indices])))
print(", ".join(author_list))
institution_list = []
for ii, institution in enumerate(institution_list_ordered):
institution_list.append('$^{%s}$ %s' % (str(ii+1), institution))
print("\n".join(institution_list))
print("--------")
institution_list = []
for ii, institution in enumerate(institution_list_ordered):
institution_list.append('\item %s' % (institution))
print("\n".join(institution_list))
if spie_style:
author_list = []
for author in authors:
author_institutions = author["affiliations"]
indices = []
for author_institution in author_institutions:
indices.append(institution_list_ordered.index(author_institution))
author_list.append('\\author[%s]{%s}' % (",".join([str(x+1) for x in indices]), author["name"]))
print("\n".join(author_list))
institution_list = []
for ii, institution in enumerate(institution_list_ordered):
institution_list.append('\\affil[%s]{%s}' % (str(ii+1), institution))
print("\n".join(institution_list))
fieldnames = ["name", "email", "affiliations", "orcid"]
with open('authors.csv', 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames = fieldnames)
writer.writeheader()
writer.writerows(authors)