Skip to content

conversion:date_pattern

timrdf edited this page Mar 25, 2011 · 24 revisions

See conversion:Enhancement. See also conversion:datetime_pattern.

conversion:date_pattern specifies how to parse a cell's literal value into a date. The pattern is specified by Java's date patterns. This only has effect when conversion:range is xsd:date.

Step 1: Change the conversion:range to xsd:date

  conversion:enhance [
     ov:csvCol         4;
     ov:csvHeader     "Completion_Date";
     conversion:label "Completion_Date";
     conversion:comment "";
     conversion:range  xsd:date;
  ];

If you run the conversion without following Step 2 (below), you will see something like this in the stderr log:

bash-3.2$ ./convert-uk-offshore-oil-wells.sh 
...
DATE FAILED: "1989-10-02" !~ 0 patterns @ :thing_2 :completion_date
...

This is telling you that the string did not match any of the zero patterns provided. So let's add some patterns!

Step 2: Add the conversion:date_pattern

This tells the converter how to parse the date.

  conversion:enhance [
     ov:csvCol         4;
     ov:csvHeader     "Completion_Date";
     conversion:label "Completion_Date";
     conversion:eg           "1989-10-02";
     conversion:date_pattern "yyyy-mm-dd";
     conversion:comment "";
     conversion:range  xsd:date;
  ];

What patterns have been used in the wild?

results

PREFIX rdfs:       <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:        <http://www.w3.org/2001/XMLSchema#>
PREFIX conversion: <http://purl.org/twc/vocab/conversion/>

SELECT distinct ?pattern
WHERE {
  GRAPH <http://purl.org/twc/vocab/conversion/ConversionProcess> {
    ?enhancement conversion:date_pattern ?pattern .
  }
}

What datasets use this enhancement?

45

PREFIX rdfs:       <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd:        <http://www.w3.org/2001/XMLSchema#>
PREFIX conversion: <http://purl.org/twc/vocab/conversion/>

SELECT count(distinct ?enhancement) as ?count
WHERE {
  GRAPH <http://purl.org/twc/vocab/conversion/ConversionProcess> {
    ?dataset a void:Dataset;
      conversion:conversion_process [
        conversion:enhance ?enhancement
      ]
    .
    ?enhancement conversion:date_pattern ?pattern .
  }
}

Clone this wiki locally