If you know the URI, do this:
# if you know what uri_x is
for s, p, o in g.triples((URIRef(uri_x), None, None)):
g.remove((s, p, o))
This will iterate through every triple with uri_x as its subject and remove it
from the graph.
Of you don’t know the URI, e.g. for a Blank Node, find it then delete:
for s, p, o in g.triples((URIRef(some_object_uri), URIRef(some_property_uri),
None)):
# o is now the Blank Node URI for the triple <some_object_uri>
<some_property_uri> <o>
# loop through all triples with o as subject and remove them
for s2, p2, o2 in g.triples((o, None, None)):
g.remove((s2, p2, o2))
You could also use a SPARQL DELETE query put to the graph via:
g.update((your_delete_query))
Nick
> On 20 Feb 2020, at 1:02 am, [email protected] wrote:
>
> I want to delete the node created either through BNode or URIRef. How should
> I do that? Any help will be highly appreciated.
> When I remove the triple, it only removes the class instantiation not the
> instance itself.
>
> --
> http://github.com/RDFLib <http://github.com/RDFLib>
> ---
> You received this message because you are subscribed to the Google Groups
> "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rdflib-dev/0dc564d8-e14c-440a-b421-85cfebb36ba8%40googlegroups.com
>
> <https://groups.google.com/d/msgid/rdflib-dev/0dc564d8-e14c-440a-b421-85cfebb36ba8%40googlegroups.com?utm_medium=email&utm_source=footer>.
______________________________________________________________________________________
Dr Nicholas Car
Data Systems Architect
SURROUND Australia Pty Ltd
Address P.O. Box 86, Mawson, Canberra ACT 2607
Phone +61 477 560 177
<tel:+61+414+99+55+43?utm_source=WiseStamp&utm_medium=email&utm_term=&utm_content=&utm_campaign=signature>
Email [email protected]
Website https://surroundaustralia.com
Enhancing Intelligence Within Organisations
delivering evidence that connects decisions to outcomes
--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rdflib-dev/D30FB8A9-8503-4CEF-A262-FF4CEF578101%40surroundaustralia.com.