Swirrl / csv2rdf

Clojure library and command line application for converting CSV to RDF. An implementation of the W3C CSVW specifications
Eclipse Public License 1.0
26 stars 6 forks source link

If given just a file via -t csv2rdf does not locate the metadata document #186

Open RickMoynihan opened 2 years ago

RickMoynihan commented 2 years ago

When running csv2rdf with just a -t table csv2rdf does not locate the metadata document, and instead performs the default conversion (note we should also provide a flag to adjust this behaviour #188).

It would be useful if csv2rdf could follow the spirit of the conventions specified in the specs for local files too.

Suggestion

NOTE: the specification falls back to RFC 5785 to specify the well-known location for the csvm templates file; however this RFC says nothing of what to do for the file:/// URI scheme.

Therefore I think the closest behaviour we can achieve here is to fallback to checking for a tool specific config folder ~/.csv2rdf/csvm, and use the template file from there; if no such template file is specified then we should use the default template file from the spec:

{+url}-metadata.json
csv-metadata.json

This would then give us the expected results where inputs like the following work:

-t file:///Users/rick/data/my-data.csv -> file:///Users/rick/data/my-data.csv-metadata.json -t ../data/my-data.csv -> ../data/my-data.csv-metadata.json

with the final fall back csv-metadata.json being resolved in terms of the original provided URI/path. Resolution here will mean that a sibling csv-metadata.json to the supplied -t file will be located.

Robsteranium commented 2 years ago

Just to expand upon this, the locating metadata section of the spec defines the precedence:

  1. overriding metadata (csv2rdf -u)
  2. find via link header
  3. find via defaults/ configuration (.well-known/csvm)
  4. use embedded metadata