from rdflib import Graph, Namespace, Literal # Define some namespaces dc = Namespace("http://purl.org/dc/elements/1.1/") census = Namespace("tag:govshare.info,2005:rdf/census/") # Create a store to hold RDF data store = Graph(); # Load the N3 file with the states data store.parse("states.n3", None, 'n3'); # Get the entity representing Pennsylvania. 'None' is like a wildcard, # so we're getting the thing that matches the statement: # ____ dc:title "Pennsylvania" pennsylvania = store.value(None, dc["title"], Literal("Pennsylvania")); # Get its population. This time we're getting the thing that matches: # pennsylvania census:population _____ population = store.value(pennsylvania, census["population"], None); print population