diff options
Diffstat (limited to 'chocula/directories/gold_oa.py')
-rw-r--r-- | chocula/directories/gold_oa.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/chocula/directories/gold_oa.py b/chocula/directories/gold_oa.py new file mode 100644 index 0000000..08747bf --- /dev/null +++ b/chocula/directories/gold_oa.py @@ -0,0 +1,44 @@ + +from typing import Iterable, Optional +import csv + +from chocula.util import clean_str +from chocula.common import DirectoryLoader +from chocula.database import DirectoryInfo + + +class GoldOALoader(DirectoryLoader): + """ + CSV Columns: + + # "ISSN","ISSN_L","ISSN_IN_DOAJ","ISSN_IN_ROAD","ISSN_IN_PMC","ISSN_IN_OAPC","ISSN_IN_WOS","ISSN_IN_SCOPUS","JOURNAL_IN_DOAJ","JOURNAL_IN_ROAD","JOURNAL_IN_PMC","JOURNAL_IN_OAPC","JOURNAL_IN_WOS","JOURNAL_IN_SCOPUS","TITLE","TITLE_SOURCE" + """ + + source_slug = "gold_oa" + + def open_file(self) -> Iterable: + return csv.DictReader(open(self.config.GOLD_OA_FILE, encoding="ISO-8859-1")) + + def parse_record(self, row) -> Optional[DirectoryInfo]: + + if not (row.get('ISSN_L') and row.get('TITLE')): + return None + + # TODO: also add for other non-direct indices + #for ind in ('WOS', 'SCOPUS'): + # issnl, status = self.add_issn( + # ind.lower(), + # raw_issn=row['ISSN_L'], + # name=row['TITLE'], + # ) + + extra = dict() + for ind in ('DOAJ', 'ROAD', 'PMC', 'OAPC', 'WOS', 'SCOPUS'): + extra['in_' + ind.lower()] = bool(int(row['JOURNAL_IN_' + ind])) + + return DirectoryInfo( + directory_slug=self.source_slug, + raw_issn=row['ISSN_L'], + name=clean_str(row['TITLE']), + extra=extra, + ) |