# Creating virtual graph when CSV contains legitimate URIs

**URL:** <https://community.stardog.com/t/creating-virtual-graph-when-csv-contains-legitimate-uris/1599>\
**Category:** Support\
**Created:** [April 15, 2019, 12:08am UTC](https://community.stardog.com/t/creating-virtual-graph-when-csv-contains-legitimate-uris/1599 "2019-04-15T00:08:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![PaulJackson](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pauljackson/32/243_2.png) [@PaulJackson](https://community.stardog.com/u/PaulJackson)\
**Post date:** [April 15, 2019, 4:20pm UTC](https://community.stardog.com/t/creating-virtual-graph-when-csv-contains-legitimate-uris/1599/2 "2019-04-15T16:20:26Z")

</div>

Hi Mark,

Welcome to the community. It seems like your idea should work given a mappings file like:

```auto
{somekey} a prefix:Entity ;
    prefix:term staticns:{termfragment} .

```

or

```auto
<{somekey}> a prefix:Entity ;
    prefix:term staticns:{termfragment} .

```

but it's running into problems. I created an issue for that.

The work-around that I was able to find was to import the CSV into an RDBMS (I used Derby - comes with Java), and use R2RML for the mappings:

```auto
ij> CONNECT 'jdbc:derby://localhost:1527/iridb;create=true';
ij> create table "iritable" ( "somekey" varchar(50), "termfragment" varchar(50));
0 rows inserted/updated/deleted
ij> INSERT INTO "iritable" ("somekey","termfragment") VALUES ('http://stardog.com/example/pjacks', 'Paul Jackson');
1 row inserted/updated/deleted

```

mappings:

```auto
@prefix prefix: <http://example.com/prefix/> .
@prefix staticns: <http://example.com/staticns/> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .

[] a rr:TriplesMap;
  rr:logicalTable [rr:tableName "\"iritable\""] ;
  rr:subjectMap [ rr:column "\"somekey\"" ;
                  rr:termType rr:IRI ;
                  rr:class prefix:Entity ] ;
  rr:predicateObjectMap [ 
    rr:predicate prefix:term ;
    rr:objectMap [rr:template "staticns:{\"termfragment\"}"]
  ] .

```

properties file:

```auto
jdbc.url=jdbc:derby://localhost:1527/iridb;create=true
jdbc.driver=org.apache.derby.jdbc.ClientDriver
jdbc.username=APP
# ignored
jdbc.password=APP

```

command-line:

```auto
stardog-admin virtual import -f r2rml mydb mydb.properties mycsv3.ttl

```

Hope that helps.  
-Paul

---

_[View the full topic](https://community.stardog.com/t/creating-virtual-graph-when-csv-contains-legitimate-uris/1599)._
