-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_authors_publication_report.py
More file actions
71 lines (66 loc) · 2.41 KB
/
run_authors_publication_report.py
File metadata and controls
71 lines (66 loc) · 2.41 KB
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
import csv
from ames.harvesters import get_records_pub_date
query = 'metadata.publisher:"American Chemical Society"&allversions=true'
records = get_records_pub_date(f"2022-01-01", f"2025-12-31", query=query)
with open("authors_publication_report.csv", "w", newline="") as csvfile:
fieldnames = [
"Authors ID",
"DOI",
"Pub Date",
"Journal",
"NSF Funded",
"NIH Funded",
"Groups",
]
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for record in records:
idv = record.get("id")
custom_fields = record.get("custom_fields")
if "journal:journal" in custom_fields:
journal = custom_fields["journal:journal"].get("title")
else:
journal = "Unknown Journal"
groups = []
if "caltech:groups" in custom_fields:
listv = custom_fields["caltech:groups"]
for group in listv:
groups.append(group["title"]["en"])
pids = record.get("pids", {})
if "doi" in pids:
doi = record["pids"]["doi"]["identifier"]
else:
doi = "No DOI"
identifiers = record["metadata"].get("identifiers", [])
for identifier in identifiers:
if identifier.get("scheme", "") == "doi":
doi = identifier.get("identifier")
date = record["metadata"].get("publication_date", "No Pub Date")
funding = record["metadata"].get("funding", [])
nsf = False
nih = False
for fund in funding:
funder = fund.get("funder", {})
if "021nxhr62" in funder.get("id", ""):
nsf = True
elif "NSF" in funder.get("name", ""):
nsf = True
elif "National Science Foundation" in funder.get("name", ""):
nsf = True
if "01cwqze88" in funder.get("id", ""):
nih = True
elif "NIH" in funder.get("name", ""):
nih = True
elif "National Institutes of Health" in funder.get("name", ""):
nih = True
writer.writerow(
{
"Authors ID": idv,
"DOI": doi,
"Pub Date": date,
"Journal": journal,
"NSF Funded": nsf,
"NIH Funded": nih,
"Groups": "; ".join(groups),
}
)