pgloader/test/csv-parse-date.load
Dimitri Fontaine 98f18c4877 Improve CSV date format, fix #293.
The date format wouldn't allow using colon (:) in the noise parts of it,
and would also insist that milliseconds should be on 4 digits and micro
seconds on 6 digits. Allow for "ragged" input and take however many
digits we actually find in the input.
2015-09-12 00:35:14 +02:00

31 lines
804 B
Fish

LOAD CSV
FROM inline
(
"row num",
ts [date format 'YYYY-MM-DD HH24-MI-SS.US'],
hr [date format 'HH24:MI.SS']
)
INTO postgresql:///pgloader?dateformat ("row num", ts, hr)
WITH truncate,
fields optionally enclosed by '"',
fields escaped by double-quote,
fields terminated by ','
SET timezone to 'Europe/Paris',
work_mem to '12MB',
standard_conforming_strings to 'on'
BEFORE LOAD DO
$$ drop table if exists dateformat; $$,
$$ create table dateformat (
"row num" smallint,
ts timestamptz,
hr time
);
$$;
1,1999-10-02 00-33-12.123456,"00:05.02"
2,2014-10-02 00-33-13.123,"18:25.52"
3,2014-10-02 00-33-14.1234,13:14.15