How to Update the Input File of an OntoRefine project in GraphDB

309 Views Asked by At

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

There are 1 best solutions below

3
tokovach On

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 [email protected] \
            -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