0

I am looking for hints how to format values in a Turtle RDF graph, rdflib for Python. Currently I get values of datatype double displayed in scientific notation:

-4.28322e-01 ; 5.175547e+01 ;

and what I need to achieve is

"-0.428322"^^xsd:double ; "51.75547"^^xsd:double ;

Tried normalize=False but still no result.

Thanks

1 Answers1

0
In [1]: from rdflib import Literal
INFO:rdflib:RDFLib Version: 4.2.1

In [2]: l = Literal(-4.28322e-01)

In [3]: l
Out[3]: rdflib.term.Literal(u'-0.428322', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#double'))

In [4]: str(l)
Out[4]: '-0.428322'

In [5]: l.n3()
Out[5]: u'"-0.428322"^^<http://www.w3.org/2001/XMLSchema#double>'
Jörn Hees
  • 3,338
  • 22
  • 44
  • Thanks! To fix it in time we used a workaround - used any value for the datatype and then replaced it with 'double' :) – City Remade Jan 05 '16 at 14:25