Create virtual graph from CSV

Based on this post Virtual Graph CSV Import I have tried the following:

[… bin]$ more mapping.ttl
@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# .
@prefix xsd: http://www.w3.org/2001/XMLSchema# .
@prefix person: http://example.com/person/ 5 .
@prefix sm: tag:stardog:api:mapping: .

person:{ID} a person:Person ;
person:title “{Title}” ;
person:firstName “{First Name}” ;
person:lastName “{Last Name}” ;
person:jobTitle “{Job Title}” ;
person:organization “{Organization}” ;
sm:map [
sm:table “Person” ;
] .
[… bin]$ more data.csv
Type,ID,Title,First Name,Last Name,Job Title,Organization
Person,121627870,Mr,Tony,McTony,Data Scientist,
Person,155342734,John,Smith,Data architect,

[… bin]$ ./stardog-admin virtual import Test2 mapping.ttl data.csv
Expected <, found 'h' [L1]

Do you know why am I getting this error?
Expected <, found 'h' [L1]

Read here or somewhere else: RDF 1.1 Turtle

Your @prefix lines should read something like

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#\> .

In other words, you are missing the <...> around the IRI of the prefix.

Matthias,

Thanks for your help. After adding the angle brackets and replacing the double quotes windows style to linux I have the following:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix person: <http://example.com/person/> .
@prefix sm: <tag:stardog:api:mapping:> .

person:{ID} a person:Person ;
person:title "{Title}" ;
person:firstName "{First Name}" ;
person:lastName "{Last Name}" ;
person:jobTitle "{Job Title}" ;
person:organization "{Organization}" ;
sm:map [
sm:table "Person" ;

So no errors this time when I run:
[… bin]$ ./stardog-admin virtual import Test2 mapping.ttl data.csv
6

So my guess that 6 triples have been added, right? However Test2 still has zero triples for some reason.

Any idea?

Thanks,
Radu

That is likely the message portion of an IndexOutOfBounds exception (the latest release gives a better error message).

This occurs if your mapping defines more fields than exist in the file. Every record must have all fields defined.

Maybe try loading just the first record to confirm that the mapping works before attempting to load all the records.

-Paul

I've had it on my todo list to look into creating an icv and archetype for r2rml and to see if using the reasoner might help with mapping files.

It would also be nice to be able use Stardog for creating and hosting mapping files so you could us ICV, reasoning, StardogStudio, VCS, etc.

You can do it right now buy you'd have to do something like

$ stardog-admin virtual import myDb dept.properties <(stardog data export deptMap -g http://mymapping/dept)

or using curl and the graph protocol, or something similar. I should mention that you'd have to use the r2rml not sms. Anyhoo, just a thought. Someone can give it a thumbs up if they think it's a good idea or let me know why it's a really stupid idea.

Yes - indeed adding a value for Organization solved the problem - thank you!

This github is also very helpful stardog-examples/examples/cli/virtual/csv at develop · stardog-union/stardog-examples · GitHub

It will help others if the tutorial Home | Stardog Documentation Latest would include a link to the above github example

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.