From 3da7d07f4a6a29c6f1768ea70ea681dfbd847e3f Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 6 Nov 2023 12:32:09 +0000 Subject: [PATCH 1/2] modify the script to split the results into 2-3 files --- ...230609_find_articles_with_invalid_issns.py | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/portality/scripts/230609_find_articles_with_invalid_issns.py b/portality/scripts/230609_find_articles_with_invalid_issns.py index 8a02d851cc..a9e9baf792 100644 --- a/portality/scripts/230609_find_articles_with_invalid_issns.py +++ b/portality/scripts/230609_find_articles_with_invalid_issns.py @@ -16,15 +16,27 @@ if __name__ == "__main__": - import argparse + # import argparse + # + # parser = argparse.ArgumentParser() + # parser.add_argument("-o", "--out", help="output file path", required=True) + # args = parser.parse_args() - parser = argparse.ArgumentParser() - parser.add_argument("-o", "--out", help="output file path", required=True) - args = parser.parse_args() + out = "out" - 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: + with open(out+"_notfound.csv", "w", encoding="utf-8") as f_notfound, open(out+"_identical.csv", "w", encoding="utf-8") as f_identical, open(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) @@ -54,4 +66,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)]) \ No newline at end of file From dffad090048437e700f093d350cff71559caf89e Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 6 Nov 2023 15:18:40 +0000 Subject: [PATCH 2/2] out param --- .../230609_find_articles_with_invalid_issns.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/portality/scripts/230609_find_articles_with_invalid_issns.py b/portality/scripts/230609_find_articles_with_invalid_issns.py index a9e9baf792..dd861ea04d 100644 --- a/portality/scripts/230609_find_articles_with_invalid_issns.py +++ b/portality/scripts/230609_find_articles_with_invalid_issns.py @@ -16,16 +16,14 @@ if __name__ == "__main__": - # import argparse - # - # parser = argparse.ArgumentParser() - # parser.add_argument("-o", "--out", help="output file path", required=True) - # args = parser.parse_args() + import argparse - out = "out" + parser = argparse.ArgumentParser() + parser.add_argument("-o", "--out", help="output file path", required=True) + args = parser.parse_args() - # 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: - with open(out+"_notfound.csv", "w", encoding="utf-8") as f_notfound, open(out+"_identical.csv", "w", encoding="utf-8") as f_identical, open(out+"_others.csv", "w", encoding="utf-8") as f_others: + + 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"])