File: csv-using-sexp.load

package info (click to toggle)
pgloader 3.6.10-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,060 kB
  • sloc: sql: 32,321; lisp: 14,793; makefile: 435; sh: 85; python: 26
file content (29 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * See https://github.com/dimitri/pgloader/issues/965
 */
LOAD CSV
     FROM INLINE(id,f1)
     INTO postgresql:///pgloader
   TARGET TABLE sexp
        (
          id,
          f1 text using (format nil "~{~a~^ ~}"
                          (split-sequence #\Space f1 :remove-empty-subseqs cl:t))
        )

     WITH truncate,
          fields terminated by ','

   BEFORE LOAD DO
    $$ drop table if exists sexp; $$,
    $$ CREATE TABLE sexp
       (
          id     int,
          f1     text
       )
    $$;


1,Hello World
2,Hello    World
2,  foobar  foobaz