Rahul
Rahul

Reputation: 11

Remove duplicates in SPARQL

Hi I have two csv data sources. The csv contains name of employees.

csv1 with heading: Name
Contents: Jack, Tom, Andy, Jim, Stella.

csv2 with heading: EmployeeName
Contents: Bella, Stefan, Jim, Cathy, Jack

?ABCInstance a ABC:TeamInstance ;
             ABC:Name ?Name .

?CDEInstance a CDE:DataInstance ;
             CDE:employeeName ?employeeName .

I want to combine values in both the variable and avoid duplicates.

What FILTER or AND or any other statements do I use?

Upvotes: 0

Views: 75

Answers (1)

HES
HES

Reputation: 157

I've had to make some assumptions about how the data in the .csv is represented in triples. If I understand correctly, something like this could work:

PREFIX ABC: <XXXXX>
PREFIX CDE: <XXXXX>

SELECT DISTINCT ?name WHERE 
{

VALUES ?entity { ABC:TeamInstance, CDE:DataInstance } .
VALUES ?hasname { ABC:Name, CDE:employeeName } .

?iri a ?entity .
?iri ?hasname ?name .

}

Upvotes: 1

Related Questions