Generate RDF graph from CSV triplets -
i need convert csv file (tab delimited triplets) [subject predicate object]
rdf graph. csv file looks this:
<http://gadm.geovocab.org/id/1_3214_geometry_1km.rdf> <http://code.google.com/p/ldspider/ns#headerinfo> _:header14010232801335542310249 _:header14010232801335542310249 <http://www.w3.org/2006/http#responsecode> 200^^<http://www.w3.org/2001/xmlschema#integer> _:header14010232801335542310249 <http://www.w3.org/2006/http#date> fri, 27 apr 2012 15:58:31 gmt _:header14010232801335542310249 <http://www.w3.org/2006/http#server> apache/2.2.16 (debian) _:header14010232801335542310249 <http://www.w3.org/2006/http#expires> sat, 28 apr 2012 15:58:31 gmt _:header14010232801335542310249 <http://www.w3.org/2006/http#content-length> 4173
my knowledge of rdf/rdf query language limited. appreciate pointers.
it looks format almost legal rdf (in n-triples syntax), might easiest fix few minor things , use rdf parser support n-triples format process file.
there's 2 things not quite correct legal n-triples:
- each line should terminated '.'
- the date values not written legal rdf literal values.
obviously, first point trivial fix. second perhaps little more challenging. rdf literal in n-triples syntax written down string in double quotes. so, convert fri, 27 apr 2012 15:58:31 gmt
legal rdf literal, you'd have put quotes around it:
"fri, 27 apr 2012 15:58:31 gmt"
however, makes string literal. if wanted go little bit further , make correctly formatted datatyped literal (using xsd:datetime
datatype, need convert proper datetime formatting. particular example need become 20120327t15:58:31z
, , in n-triples datatype appended literal using ^^<datatype-url>
syntax, become:
"20120327t15:58:31z"^^<http://www.w3.org/2001/xmlschema#datetime>
putting together, complete line become:
_:header14010232801335542310249 <http://www.w3.org/2006/http#date> "20120327t15:58:31z"^^<http://www.w3.org/2001/xmlschema#datetime> .
alternatively, if find there other parts of csv file problematic convert, can use old csv parser , write small program reads csv file , creates rdf statements values, using rdf framework/api in programming language of choice.
Comments
Post a Comment