Create virtual graph from CSV

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

[… bin]$ more mapping.ttl
@prefix rdf: .
@prefix xsd: .
@prefix 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:

Your @prefix lines should read something like

@prefix rdf: <> .

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


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

@prefix rdf: <> .
@prefix xsd: <> .
@prefix 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

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

Any idea?


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.


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 <(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

It will help others if the tutorial 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.