Reputation: 65
I want to process a .csv file using the PHDD ontology and output the data into the JSON-LD format. Can anyone give me a good example of how to do this?
Upvotes: 0
Views: 43
Reputation: 1906
You likely want to use the CSV on the Web to transform the CSV into RDF. As JSON-LD is an RDF serialization, you can use a variety of tools to output your JSON-LD.
For example, the Ruby linkeddata gem can be used to do all of this, either programmatically, or using the command-line.
The first step is to create a metadata file which can be used to interpret data in your CSV. There are then different tools that can be used to create RDF from this (either including provenance information from the CSV, or just outputting the raw data). For example, the metadata file for the RDF Tabular gem DOAP description applies to the CSV version of the project DOAP. By pointing a processor at the (raw version of the) CSV file, it will automatically find the metadata file. You can tell the rdf command to take this input and serialize it as JSON-LD in one step.
rdf serialize --input-format tabular https://raw.githubusercontent.com/ruby-rdf/rdf-tabular/develop/etc/doap.csv --output-format jsonld
The implementation report lists some implementations of CSV on the Web, and since then others have likely emerged.
Upvotes: 1