From 6f2be7cd6a2e7c6af842aade654ac638db7d80ec Mon Sep 17 00:00:00 2001 From: Lorenzo Vagliano Date: Tue, 12 Nov 2024 16:22:59 +0100 Subject: [PATCH] fix(export): Filtered author export based on Country Signed-off-by: Lorenzo Vagliano --- scoap3/utils/tools.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/scoap3/utils/tools.py b/scoap3/utils/tools.py index 91d055a1..06a2c6f9 100644 --- a/scoap3/utils/tools.py +++ b/scoap3/utils/tools.py @@ -134,24 +134,22 @@ def author_export(search_year, search_country): author_last_name = author.get("last_name", "UNKNOWN") # add extracted information to result list for affiliation in author.affiliations: - if not affiliation.country: - aff_country = "UNKNOWN" - else: + if affiliation.country.code == search_country: aff_country = affiliation.country.code - aff_value = affiliation.get("value", "UNKNOWN") - result_data.append( - [ - year, - journal, - doi, - arxiv, - arxiv_category, - author_first_name + " " + author_last_name, - aff_country, - aff_value, - total_authors, - ] - ) + aff_value = affiliation.get("value", "UNKNOWN") + result_data.append( + [ + year, + journal, + doi, + arxiv, + arxiv_category, + author_first_name + " " + author_last_name, + aff_country, + aff_value, + total_authors, + ] + ) if missing_author_affiliations: logger.warn(