If condition while creating virtual graph out of CSV

In the SMS cars.ttl example I see the following:

:Car-{_ROW_} a vso:Automobile, gr:ActualProductOrServiceInstance ;
    rdfs:label "{Make} {Model} ({Year})" ;
    gr:hasManufacturer :Manufacturer-{#Make} ;
    gr:hasMakeAndModel :Model-{#Model} ;
    vso:modelDate "{Year}-01-01"^^xsd:date .
  • Is it possible to place an if condition so that only for the first row in the CSV such a triple is created?


Hi Radu,
What would that accomplish?

My example is not car related. What I need is to add another type to the subject instance if row=1.

You would have to perform this using a SPARQL update:

insert { ?x a :NewType }
where {
# conditions on ?x

Hope this helps.

So no if condition in stardog mapping syntax yet ...

One more idea - is to add an extra column in (each) csv with only one value in the first row for that column. Then make the corresponding change in ttl.

Is _ROW_ something you can use in mappings? I don't recall having seen it in the docs.

It looks like _ROW_ and _UUID_ are currently only documented in the example: https://github.com/stardog-union/stardog-examples/blob/develop/examples/cli/virtual/csv/cars_mappings.ttl#L31

I will add them to the docs. Thanks.

1 Like

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