How to add more data to the existing Stardog database though csv file

Hi stardog team,

I want to know how can we add more data through new csv file to the existing database. I have written an example of the issue I am facing. Please help:

I have a stardog database that I have created by importing csv file. Let's say the csv file is:

Car_id,Car_name,Car_owner
23 , Ford , James
31 , BMW , Dane
14 , Fiat , Mary

The above csv file create three instances of class car with IRI as Car_id

Now, I want to add more details about those cars with a new csv file in the same database. New csv is:

Car_id,Car_Capacity,Car_age
23 , 4 ,1.5
31 , 2 ,2
14 , 6 ,0.5

I want to add this new data such that the previous 3 nodes with Car_id IRI has now additional details of Car_Capacity and Car_age, without creating again 3 new nodes.

So, finally I want these 3 Car_id IRI to have 4 attributes : Car_Name, Car_owner , Car_Capacity and Car_age.

Can you please help me in solving above problem.

Thanks

Thought I prefer building my own mapping, I assume that you are using the auto generated map.

Therefore, If I take your csv (and remove space beside comma), and use the following properties

#cars.properties
base=http://example.com/cars#
csv.class=http://example.com/class/Cars
unique.key.sets=(Car_id)

and load you example with the command

stardog-admin virtual import myDB cars.properties csv1.csv
stardog-admin virtual import myDB cars.properties csv2.csv

All seems fine

❯ stardog query myDB "select ?p ?o {<http://example.com/cars#/Car_id=23>  ?p ?o }
"
+---------------------------------------+-------------------------------+
|                   p                   |               o               |
+---------------------------------------+-------------------------------+
| rdf:type                              | http://example.com/class/Cars |
| http://example.com/cars##Car_age      | "1.5"                         |
| http://example.com/cars##Car_Capacity | "4"                           |
| http://example.com/cars##Car_id       | "23"                          |
| http://example.com/cars##Car_name     | "Ford"                        |
| http://example.com/cars##Car_owner    | "James"                       |
+---------------------------------------+-------------------------------+

Can you elaborate more on how you are loading it?

1 Like

Hi Serge,
Thanks, this solved my doubt. Previously, I am adding the csv file through Stardog studio. There is no option of attaching properties file in studio. After using command line, it works fine. Thanks once again.

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