Questions tagged [rdflib]

RDFLib is a Python library for working with RDF. It supports parsers and serializers for different syntaxes (RDF/XML, N3, N-Triples, Turtle, TriX and RDFa) as well of remote and local SPARQL queries. Please do not use this tag for rdflib.js.

Resources

Please do not confuse the RDFLib Python library with the rdflib.js Javascript library.

439 questions
7
votes
2 answers

INSERT/DELETE/UPDATE query using SPARQLWrapper

Although I have gone through lot of examples on the web explaining the use of python SPARQLWrapper using SELECT statements for fetching data from sesame triple store, but not sure how can we INSERT/DELETE/UPDATE statements in sesame using it. Can…
imran
  • 199
  • 3
  • 11
6
votes
3 answers

Creating RDF file using csv file as input

I need to convert a csv file to rdf with rdflib, I already have the code that reads the csv but I do not know how to convert it to rdf. I have the following code: import csv from rdflib.graph import Graph # Open the input file with open('data.csv',…
sanandresm
  • 61
  • 1
  • 2
  • 3
6
votes
1 answer

Using owl:Class prefix with rdflib and xml serialization

I would like to use the owl: prefix in the XML serialization of my RDF ontology (using rdflib version 4.1.1); unfortunately I'm still getting the serialization as rdf:Description tags. I have looked at the answer about binding the namespace to the…
bbengfort
  • 5,254
  • 4
  • 44
  • 57
6
votes
0 answers

Adding triples to Virtuoso triplestore with Python and RDFLib

I need to make a program to add triples to a Virtuoso triplestore, I'm using Python and RDFLib. I've installed the Virtuoso plugin and tried a connection as seen in http://pythonhosted.org/virtuoso/rdflib.html#virtuoso-storage. I got: from…
FontFranch
  • 61
  • 3
6
votes
1 answer

Using contexts in rdflib

I am having trouble finding a clear, sensible example of usage of context with rdflib. ConjunctiveGraph does not accept contexts, and Graph is deprecated. How am I supposed to create and operate on different contexts within the same global…
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
6
votes
1 answer

Is there a Hello World example for SPARQL with RDFLib?

I would like to get as small as possible but still self-consistent and working example of using SPARQL from RDFLib. I have RDFLib version '4.0.1'. I would like to have a code that does the following Import RDFLib. Creates a simple Graph (from 2 to…
Roman
  • 124,451
  • 167
  • 349
  • 456
5
votes
1 answer

Namespace binding in RDFLib

In the following minimal test case: from rdflib import Graph, Namespace, Literal, RDF base = "http://test.com/ns" foobar = Namespace("http://test.com/ns#") g = Graph(base=base) g.bind('foobar', foobar) g.add((foobar.something, RDF.type,…
Balduin
  • 415
  • 4
  • 11
5
votes
1 answer

REST API for SPARQL in Django (Python)?

Introduction The challenge I bring to you today is: To implement a Real Rime REST API (GET, POST, PUT, DELETE, etc) to query and update any SPARQL endpoint using the Django REST Framework for a frontend application (I am using React) to request and…
Daniel
  • 87
  • 10
5
votes
1 answer

Python: Using RDFLIB to graph a Sesame database

Is it possible to draw a graph of a Sesame RDF database using RDFLIB? This is what I tried: endpoint = "http://127.0.0.1:8080/openrdf-workbench/repositories/movies/explore?resource=%3Cfile%3A%2F%2Fmovies_export.rdf%3E" from rdflib import Graph g…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
5
votes
3 answers

How to access members of an rdf list with rdflib (or plain sparql)

What is the best way to access the members of an rdf list? I'm using rdflib (python) but an answer given in plain SPARQL is also ok (this type of answer can be used through rdfextras, a rdflib helper library). I'm trying to access the authors of a…
tjb
  • 11,480
  • 9
  • 70
  • 91
5
votes
1 answer

Using a prefix in RDFLIB

I would like to use a short prefix to designate a namespace in rdflib but I am having trouble. I think the answer must be very simple. Here is the offending code: g =…
tjb
  • 11,480
  • 9
  • 70
  • 91
5
votes
1 answer

RDFLib: Namespace prefixes in XML serialization

In a Python script using RDFLib 3.0, I get the following XML-Output when serializing my triples: How can I define specific namespace prefixes for those anonymous _x-prefixes…
sam
  • 1,406
  • 2
  • 15
  • 25
5
votes
1 answer

How do I print term literal from rdflib in a readble way?

I just started using rdflib and I have a program that needs to get the birth date of a person (in this example, Lewis Carroll). My program does that, however when I try to print the date it prints: (rdflib.term.Literal('1832-01-27',…
Lior Sapir
  • 53
  • 1
  • 4
5
votes
1 answer

Force rdflib to define a namespace

I am starting to use the rdflib library for dealing with rdf data in Python. At the moment, I want to create a .n3 file of some rdf graph that looks like this: @prefix ns1: . @prefix ns2:…
5xum
  • 5,250
  • 8
  • 36
  • 56
5
votes
2 answers

Filtering data in SPARQL query using python script

I am trying to get uri against firstname literal of the user using following query in RDFlib Python. plugin.register( 'sparql', rdflib.query.Processor, 'rdfextras.sparql.processor', 'Processor') plugin.register( 'sparql',…
imran
  • 199
  • 3
  • 11
1
2
3
29 30