Skip to content

conversion:datetime_pattern

timrdf edited this page Aug 22, 2012 · 19 revisions
csv2rdf4lod-automation is licensed under the [Apache License, Version 2.0](https://github.com/timrdf/csv2rdf4lod-automation/wiki/License)

See conversion:Enhancement. See also conversion:date_pattern.

Patterns are now processed with Joda time.

Patterns used to be processed by Java's SimpleDateFormat.

Tue 14 Dec 2010 01:49:21 +0000

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

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

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 
...
DATETIME FAILED: "Tue 14 Dec 2010 01:49:21 +0000" !~ 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:datetime_pattern

This tells the converter how to parse the date. It is also very helpful to include a sample value using conversion:eg, so you can see an example while you determine the pattern. It is also helpful for documentation in the future.

  conversion:enhance [
     ov:csvCol         4;
     ov:csvHeader     "Completion_Date";
     conversion:label "Completion_Date";
     conversion:eg           "Tue 14 Dec 2010 01:49:21 +0000";
     conversion:datetime_pattern "EEE dd MMM yyyy HH:mm:ss Z";
     conversion:comment "";
     conversion:range  xsd:dateTime;
  ];

Patterns should be specified using Java's SimpleDateFormat, whose table of variables is reproduced here:

snapshot of Java's SimpleDateFormat patterns

Queries

What kinds of patterns have been applied to promote literal strings to date times (results)?:

prefix conversion: <http://purl.org/twc/vocab/conversion/>

select distinct ?datetime
where {
  graph <http://purl.org/twc/vocab/conversion/ConversionProcess> {
    ?dataset conversion:conversion_process [
      conversion:enhancement_identifier ?e;
      conversion:enhance [ 
        conversion:datetime_pattern ?datetime
      ]
    ] 
  }
}
Clone this wiki locally