I'm trying to script RDF/OWL data (re)loading to a GraphDB store and I wonder how to be able to process again a CSV file through the Ontorefine component, keeping the columns modifications and the RDF mapping, only using the REST API.
1 Answers
One way to script this is by using the rdf-mapper REST API, which accepts a column mapping file and a tabular file and streams the result to an input location file.
This file can afterwards be imported into GraphDB by using the import server file REST API (for which more information can be found here https://graphdb.ontotext.com/free/devhub/workbench-rest-api/curl-commands.html#data-import ).
Please keep in mind that when starting GraphDB, you need to input the directory from which you plan to import the RDF file by using this property:
-Dgraphdb.workbench.importDirectory=/import/location/
Here is a small example script of how you can import a CSV file as RDF .ttl document using cURL:
curl -X POST -sL \
--url "http://address:port/rest/rdf-mapper/rdf/stream:csv:separator={CSV-SEPERATOR}"\
-F mapping=@mapping.json \
-F data=@import_file.csv \
-H 'accept: text/turtle' \
-o export_file.ttl
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"fileNames": [
"export_file.ttl"
],
"importSettings": {
"baseURI": "",
"context": "",
"parserSettings": {
"failOnUnknownDataTypes": true,
"failOnUnknownLanguageTags": true,
"normalizeDataTypeValues": true,
"normalizeLanguageTags": true,
"preserveBNodeIds": true,
"stopOnError": true,
"verifyDataTypeValues": true,
"verifyLanguageTags": true
}
}
}' 'http://address:port/rest/data/import/server/{REPOSITORY-NAME}'
P.S. Here is how to create the needed mapping.json by using GraphDB Workbench and following these steps: Go to Ontorefine -> Select and Import a tabular file -> Select Create Project -> Select RDF Mapping / Edit RDF Mapping -> Then a new window opens where you can configure the said mapping -> After configuring the mapping select "Download JSON" . The downloaded JSON mapping can be used then with the example provided above.
For more information take a look at https://graphdb.ontotext.com/free/loading-data-using-ontorefine.html?highlight=mapping

- 96
- 3
-
Thank you for your answer. I wonder how to create the mapping.json file. Could we get it from an export of a Ontorefine project ? – Laurent Pierre Dec 11 '20 at 10:08
-
You can create an RDF Mapping (mapping.json) by using GraphDB Workbench and following these steps: Go to Ontorefine -> Select and Import a tabular file -> Select Create Project -> Select RDF Mapping / Edit RDF Mapping -> Then a new window opens where you can configure the said mapping -> After configuring the mapping select "Download JSON" . The downloaded JSON mapping can be used then with the example provided above. For more information take a look at https://graphdb.ontotext.com/free/loading-data-using-ontorefine.html?highlight=mapping – tokovach Dec 11 '20 at 11:40
-
@tokovach how do you create rdf mapping when your excel data needs some values from linked data(depedia) ? – slm12slm slm12slm Dec 30 '20 at 15:36