Skip to content

Commit

Permalink
Merge tag '3725_improve_script' into develop
Browse files Browse the repository at this point in the history
Split results into multiple files
  • Loading branch information
Steven-Eardley committed Nov 6, 2023
2 parents 6c85bda + 4fdec0b commit 225665c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions portality/scripts/230609_find_articles_with_invalid_issns.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@
parser.add_argument("-o", "--out", help="output file path", required=True)
args = parser.parse_args()

with open(args.out, "w", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["ID", "PISSN", "EISSN", "Journals found with article's PISSN", "In doaj?", "Journals found with article's EISSN", "In doaj?", "Error"])

with open(args.out+"notfound.csv", "w", encoding="utf-8") as f_notfound, open(args.out+"-identical.csv", "w", encoding="utf-8") as f_identical, open(args.out+"-others.csv", "w", encoding="utf-8") as f_others:
writer_notfound = csv.writer(f_notfound)
writer_notfound.writerow(["ID", "PISSN", "EISSN", "Journals found with article's PISSN", "In doaj?",
"Journals found with article's EISSN", "In doaj?", "Error"])

writer_identical = csv.writer(f_identical)
writer_identical.writerow(["ID", "PISSN", "EISSN", "Journals found with article's PISSN", "In doaj?",
"Journals found with article's EISSN", "In doaj?", "Error"])

writer_others = csv.writer(f_others)
writer_others.writerow(["ID", "PISSN", "EISSN", "Journals found with article's PISSN", "In doaj?",
"Journals found with article's EISSN", "In doaj?", "Error"])

for a in models.Article.iterate(q=IN_DOAJ, page_size=100, keepalive='5m'):
article = models.Article(_source=a)
Expand Down Expand Up @@ -54,4 +64,9 @@
j_e_in_doaj.append(jobj.is_in_doaj())
else:
j_e_in_doaj.append("n/a")
writer.writerow([id, pissn, eissn, j_p, j_p_in_doaj, j_e, j_e_in_doaj, str(e)])
if (str(e) == "The Print and Online ISSNs supplied are identical. If you supply 2 ISSNs they must be different."):
writer_identical.writerow([id, pissn, eissn, j_p, j_p_in_doaj, j_e, j_e_in_doaj, "Identical ISSNs"])
elif (str(e) == "ISSNs provided don't match any journal."):
writer_notfound.writerow([id, pissn, eissn, j_p, j_p_in_doaj, j_e, j_e_in_doaj, "No matching journal found."])
else:
writer_others.writerow([id, pissn, eissn, j_p, j_p_in_doaj, j_e, j_e_in_doaj, str(e)])

0 comments on commit 225665c

Please sign in to comment.