-
Notifications
You must be signed in to change notification settings - Fork 9
3. Additional Features
Beyond transposing a csv file into Linked Open Data, CoW includes two additional features.
- convert CSVs containing URIs
- Export Linked Data in other RDF formats
When a CSV file already contains Linked Data, there are two ways to include them properly in your dataset. Often the CSV contains an additional column with URI's denoting the ID's. Below we build on the buurt.csv example. In this table the ID's are followed by 'names' of neighbourhoods, indicated by a letter, and the URI next to it.
"id","buurt1853","adamBUri1853"
"21519","M","https://adamlink.nl/geo/district/buurt-m/132"
"21520","M","https://adamlink.nl/geo/district/buurt-m/132"
Two data types can transpose these URIs to Linked Data.
The first data type is "xsd:anyURI"
. To indicate that the subject (?s
) is related to the column indicating the neighborhood URI's linked to adamlink.nl, change the predicate (?p
) to "skos:related"
.
{
"titles": [
"adamBUri1853"
],
"@id": "https://iisg.amsterdam/anyUri.csv/column/adamBUri1853",
"name": "adamBUri1853",
"datatype": "xsd:anyURI",
"dc:description": "adamBUri1853",
"propertyUrl": "skos:related"
},
The second data type used to transpose URI's from a CSV to Linked Data is xsd:linkURI
. This datatype defines a relation between the subject (?s
) and object (?o
).
Sometimes, you may want to work with the URI in the aboutUrl
. For example, if you would like to define a relation (e.g. skos:related
) between the subject (aboutUrl
) and object (valueUrl
). In that case, all we have to do is change the datatype
into xsd:linkURI
:
{
"virtual": true,
"aboutUrl": "{id_person}",
"propertyUrl": "OWL:sameAs",
"valueUrl": "{id_country}",
"datatype": "xsd:linkURI"
}
There are various formats to represent triples. By default CoW uses so called 'nquads', because in addition to the triple it provides provenance on the triple in a fourth statement:
<https://iisg.amsterdam/6> <http://www.w3.org/2004/02/skos/core#related> <https://adamlink.nl/geo/district/buurt-mm/109> <https://iisg.amsterdam/anyUri/assertion/e69b104d/2019-02- 12T14:46> .
Since multiple provenance statements in a single file quickly appear messy, sometimes people prefer another format. Turtle (.ttl) for instance represents triples in a friendlier format that is easier on the eye for humans:
<https://iisg.amsterdam/6> ns3:related <https://adamlink.nl/geo/district/buurt-mm/109> ;
ns2:buurt1853 "MM"^^xsd:string ;
ns2:id "21525"^^xsd:string .
Notice how all triples are neatly grouped and indented for one subject (https://iisg.amsterdam/6).
In CoW you can choose the desired format of your triples by upgrading CoW to the latest version >.40
using pip install cow_csvw --upgrade
. Add the --format
option of your liking. Run cow_tool --help
to see all available options. The following example converts a file called anyUri.csv
from the Downloads folder to Turtle:
cow_tool --format turtle convert ~/Downloads/anyUri.csv
CoW is built on QBer, part of the datalegend ecosystem for historical statistics. For more tools, datasets and infrastructure please visit https://datalegend.net. datalegend is a work package within CLARIAH a back-to-back NWO funded large research facility (#184.033.101)