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
2
votes
0 answers

How to parse large triple files?

Is there a way to breakdown large triple files (any format), so that they can be parsed? I am currently attempting to load a LOD data dump into a local triplestore using python (rdflib). Also, is there a better (in terms of scalability) alternative…
RDangol
  • 179
  • 9
2
votes
0 answers

How do I get the base uri of an xml file using rdflib?

I'm using python's rdflib package to parse RDF xml as triples. I am comparing multiple files, and I want to be able to check that the base URI defined in the tag as xml:base is the same accross two files. My code for reading in the libary…
AnjoMan
  • 4,838
  • 4
  • 20
  • 28
2
votes
0 answers

Unicode encoding error with Python rdflib output

I am using rdflib to parse CommonCrawl microdata. It is a big N-Quads format file. Everything is fine except the very last stage of saving to a CSV file or printing to the terminal, as it fails with encoding errors. My current code is: import…
samiles
  • 3,768
  • 12
  • 44
  • 71
2
votes
1 answer

How to process a .ttl file of 3 attributes using rdflib (python 3.x)?

I have a .ttl file which consists of 3 attributes. Ex: "James B. McLeran"@en . How can I parse and store these attributes using RDFlib? Expected output:…
Gita
  • 149
  • 1
  • 9
2
votes
0 answers

How to implement an ontology for a simple website

I currently have developed a few websites (using Django, Flask, Symfony, etc...). I have also developed Ontologies using semantic software (PoolParty) for enterprise size companies. I would like to use a small ontology to link data currently in the…
2
votes
2 answers

rdflib - Querying Persistence store

I'm quite new to linked data and rdflib and I'm quite lost. I am trying to use rdflib to make a persistence store with 'Sleepycat' to load the DBLP database rdf file and then start querying it.This is what I've done: import rdflib graph =…
DMD
  • 103
  • 1
  • 8
2
votes
1 answer

Adding triple containing blank node to Stardog with RDFLib

I'm using the RDFLib Python library to manipulate a Stardog database. How do I add a blank node? I'm trying g.add((BNode(),FOAF.knows,Literal('amy'))), but I get an exception "SPARQLStore does not support Bnodes!". What is the alternative?
2
votes
1 answer

how to interrogate ontology with sparql, rdflib in python

I have developed my own ontology (I defined my classes, properties, etc.) and I want to interrogate my ontology with sparql. in protégé 2000 (open-source ontology editor) everything works fine, but when I want to implement my request sparql in…
Mehdi
  • 21
  • 1
  • 6
2
votes
2 answers

Parsing RDF from Gutenberg in Python

I'm looking to parse the Gutenberg catalog available here using Python. I'm experienced at web scraping and parsing HTML, but this format eludes me. I've tried using the lxml etree and the below attempt at using RDFlib: path = 'epub/10/pg%s.rdf' g =…
T. Arboreus
  • 1,067
  • 1
  • 9
  • 17
2
votes
1 answer

Error in query while inserting data using RDFlib to GraphDB

I parse a database into an RDFlib graph. I now want to INSERT the triples from this graph into the GraphDB triple store. The code works fine when I execute it on an older version of GraphDB-Lite hosted on Sesame. However, I get an error while…
kurious
  • 1,024
  • 10
  • 29
2
votes
1 answer

rdflib SPARQL queries (involving subclasses) not behaving as expected

I have just started to self-learn RDF and the Python rdflib library. But I have hit an issue with the following code. I expected the queries to return mark and nat as Persons and only natalie as a Professor. I can't see where I've gone wrong. (BTW,…
2
votes
1 answer

RDF/XML rdflib: Invalid property element URI

I am trying to parse an RDF/XML file in python with rdflib. The file validates OK with the W3 validator, however rdflib throws the Parser Error 7:6: Invalid property element URI: http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF. The same happens when…
Matt B
  • 45
  • 4
2
votes
1 answer

use of FOPLRelationalModel.MySQLMassLoader

I am trying to use FOPLRelationalModel.MySQLMassLoader from rdflib but when I use,it shows /usr/bin/python: No module named rdflib.store.FOPLRelationalModel.MySQLMassLoader I have tried installing rdfextras also but that is also not…
aditi rana
  • 35
  • 6
2
votes
1 answer

Python RDF lib - String value for nodes

I am using RDF lib to retrieve values from an online triple store. I was wondering whats the ideal way of turning URIRef and Literals to plain string objects? For example : value = g.value(s,FOAF.page) Should I be using value.n3(), or…
Giannis
  • 5,286
  • 15
  • 58
  • 113
2
votes
2 answers

Can't get RDFlib to work on windows

I have installed RDFlib 3.0 and everything that is needed, but when I run the following code I get an error. The code below is from: http://code.google.com/p/rdflib/wiki/IntroSparql. I have tried for hours to fix this but with no success. Can please…
john
  • 315
  • 3
  • 5