diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-24 22:50:16 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-09-24 22:50:16 -0700 |
commit | 979d21ff54273ff3942e34d244e585287a1d6c79 (patch) | |
tree | 5e4baf6be2e0ab1c177ddd6488d6ded6616857d7 /python | |
parent | 91f6b6cd6d0be7f36e3f9c1d93268c5ea34f2d91 (diff) | |
download | fatcat-979d21ff54273ff3942e34d244e585287a1d6c79.tar.gz fatcat-979d21ff54273ff3942e34d244e585287a1d6c79.zip |
parse 'issued' date format correctly
Diffstat (limited to 'python')
-rw-r--r-- | python/fatcat/crossref_importer.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/python/fatcat/crossref_importer.py b/python/fatcat/crossref_importer.py index fb227a6a..c3e8f9db 100644 --- a/python/fatcat/crossref_importer.py +++ b/python/fatcat/crossref_importer.py @@ -2,6 +2,7 @@ import sys import json import sqlite3 +import datetime import itertools import fatcat_client from fatcat.importer_common import FatcatImporter @@ -194,6 +195,12 @@ class FatcatCrossrefImporter(FatcatImporter): if max(len(contribs), len(refs), len(abstracts)) > 750: return None + release_date = obj['issued']['date-parts'][0] + if len(release_date) == 3: + release_date = datetime.datetime(year=release_date[0], month=release_date[1], day=release_date[2]) + else: + release_date = datetime.datetime(year=release_date[0], month=1, day=1) + re = fatcat_client.ReleaseEntity( work_id=None, title=obj['title'][0], @@ -209,7 +216,7 @@ class FatcatCrossrefImporter(FatcatImporter): pmid=extids['pmid'], pmcid=extids['pmcid'], wikidata_qid=extids['wikidata_qid'], - release_date=obj['issued']['date-time'], + release_date=release_date.isoformat() + "Z", issue=obj.get('issue'), volume=obj.get('volume'), pages=obj.get('page'), |