I have a file in .ttl
form. It has 4 attributes/columns containing quadruples of the following form:
(id, student_name, student_address, student_phoneno)
. (id, faculty_name, faculty_address, faculty_phoneno)
.I know how to parse .n3
form triples with RDFLib;
from rdflib import Graph
g = Graph()
g.parse("demo.nt", format="nt")
but I am not sure as to how to parse these quadruples.
My intent is to parse and extract all the information pertaining to a particular id. The id can be same for both student and faculty.
How can I use RDFLib to process these quadruples and use it for aggregation based on id
?
Example snippet from .ttl
file:
#@ <id1>
<Alice> <USA> <12345>
#@ <id1>
<Jane> <France> <78900>
If you cannot open your TTL file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a TTL file directly in the browser: Just drag the file onto this browser window and drop it.
RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information. This library contains parsers/serializers for almost all of the known RDF serializations, such as RDF/XML, Turtle, N-Triples, & JSON-LD, many of which are now supported in their updated form (e.g. Turtle 1.1).
Looks like turtle is supported at least as of rdflib 5.0.0. I did
from rdflib import Graph
graph = Graph()
graph.parse('myfile.ttl', format='ttl')
This parsed in just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With