Import CSV data

Step by step guide to converting CSV data to RDF and importing into end-user application

Read more on how CSV imports work.

There are 3 main components that comprise a CSV import:

CSV file
The file containing the tabular data
Mapping query
SPARQL CONSTRUCT query that maps CSV to generic RDF represenation
CSV import
Combines the file with the corresponding query

LinkedDataHub allows all the import components be created from a single dialogue, but we will go through the process in separate steps:

  1. First, create a container for the data to be imported. This will be the import's target container
  2. Upload a CSV file. Click on the Create dropdown in the top left-hand corner and select File. This will open a new form.
  3. Fill out Item fields
  4. Fill out the mandatory File fields:
    Filename
    Click on Choose file and select a CSV file from your computer
    Title
    File title
  5. Once all the fields have been filled in, click Save
  6. The browser will open your imported file
  7. Create a mapping query that will transform the uploaded CSV to RDF. Click on the Create dropdown in the top left-hand corner and select CONSTRUCT. This will open a new form.
  8. Fill out Item fields
  9. Fill out the mandatory Query fields:
    Text
    SPARQL CONSTRUCT query string
    You will not be able to save the query if its syntax is not valid SPARQL 1.1.
    Title
    Query title
  10. Once all the fields have been filled in click Save. You can find this saved under Queries container in left navigation.
  11. Click on the Create dropdown button at the top left-hand corner and select CSV Import. This will open a new form.
  12. Fill out Item fields
  13. Fill out the mandatory CSV Import fields:
    File
    Start typing the name of your CSV file and select it from the typeahead.
    Query
    Select the mapping query using the typeahead.
    Title
    Import title
  14. Click Save and you will be redirected the newly created import document.
  15. Refresh the document after a couple of moments to see the import progress. In case of success, the amount of data imported will be displayed. In case of failure, constraint violation(s) or other import issues will be displayed.
  16. Go back to the target container to see the newly imported data items.

Checkout the Command line interface (CLI) scripts into a folder on your machine. Provide a list of arguments to the import-csv script and execute it. For example:

./import-csv.sh \
    -b https://localhost:4443/ \
    -f "$cert_pem_file" \
    -p "$cert_password" \
    --title "Places" \
    --query-file places.rq \
    --file places.csv