Import CSV data
Step by step guide to converting CSV data to RDF and importing into end-user application
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
- Connects the file with the corresponding query and submits the transformed RDF data to the specified action container
LinkedDataHub allows all the import components be created from a single dialogue, but we will go through the process in separate steps:
- First, create a container for the data to be imported. This will be the import's target container
- Upload a CSV file. Click on the Create button in the top left-hand corner and select File. This will open a new form.
-
Fill in the mandatory fields:
- Title
- File title
- Filename
- Click on Choose file and select a CSV file from your computer
- Title
- Document title
- Once all the fields have been filled in, click Save
- The browser will open your imported file
- Create a mapping query that will transform the uploaded CSV to RDF. Click on the Create button in the top left-hand corner and select CONSTRUCT. This will open a new form.
-
Fill out the mandatory 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
- Title
- Document title
- Once all the fields have been filled in click Save. You can find this saved under Queries container in left navigation.
- Click on the Create button at the top left-hand corner and select CSV import. This will open a new form.
-
Fill out the mandatory fields:
- File
- Start typing the name of your CSV file and select it from the typeahead.
- Query
- Select the corresponding mapping query using the typeahead.
- Target container
- Select the target container using the typeahead.
- Title
- Import title
- Title
- Document title
- Click Save and you will be redirected the newly created import document.
- 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.
- 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://linkeddatahub.com/my-context/my-app/ \ -f linkeddatahub.pem \ -p CertPassword \ --title "Places" \ --query-file places.rq \ --file places.csv \ --action "${base}places/"