Error on parse datetime in custom format

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error on parse datetime in custom format

Alexander
Hey there,

I just tried to work with loaded Cell Ontology (can be downloaded here: https://bioportal.bioontology.org/ontologies/CL) and got some errors when tried to get datetime attributes:

File "/c/dev/sciai/xtr-ontologies/modules/parsers/owl_parser.py", line 166, in _get_attr_or_none
    values = Prop._get_values_for_class(obj)
  File "/c/dev/sciai/xtr-ontologies/venv/lib/python3.6/site-packages/owlready2/prop.py", line 290, in _get_values_for_individual
    entity, Prop)
  File "/c/dev/sciai/xtr-ontologies/venv/lib/python3.6/site-packages/owlready2/prop.py", line 953, in __init__
    list.__init__(self, l)
  File "/c/dev/sciai/xtr-ontologies/venv/lib/python3.6/site-packages/owlready2/prop.py", line 289, in <genexpr>
    return IndividualValueList((entity.namespace.ontology._to_python(o, d) for o, d in entity.namespace.world._get_triples_sp_od(entity.storid, Prop.storid)),
  File "/c/dev/sciai/xtr-ontologies/venv/lib/python3.6/site-packages/owlready2/namespace.py", line 225, in _to_python
    else: return from_literal(o, d)
  File "/c/dev/sciai/xtr-ontologies/venv/lib/python3.6/site-packages/owlready2/base.py", line 59, in from_literal
    return parser(o)
  File "/c/dev/sciai/xtr-ontologies/venv/lib/python3.6/site-packages/owlready2/base.py", line 164, in <lambda>
    lambda s: datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%S"),
  File "/usr/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/lib/python3.6/_strptime.py", line 365, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: Z


In OWL file I can find the following attributes:

<oboInOwl:creation_date rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2017-09-17T13:52:24Z</oboInOwl:creation_date>

It looks like owlready2 tries to parse any attributes with datetype "http://www.w3.org/2001/XMLSchema#dateTime" as "%Y-%m-%dT%H:%M:%S".

How can I avoid this error?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Error on parse datetime in custom format

Jiba
Administrator
Hi,

I've added more datetime format, in the development version of Owlready (on BitBucket). It should new be Ok!

Jiba