2

I am using pgloader to load file into Tables. I need to load constant (ie, field not provided by the csv) but I do not succeed.

my configuration looks like :

LOAD CSV  
  FROM './file.csv'
  HAVING FIELDS
  (a, b, c)
INTO postgresql:///pgloader?my_table
  TARGET COLUMNS
  (
    a
    ,b   
    ,c  
    ,Src
  )
  WITH
    skip header = 0,  
    fields optionally enclosed by '"',  
    fields escaped by double-quote,  
    fields terminated by ';'  
;

and I need to put 'SRC' static value into the field my_table.Src.

Do you have any idea?

Thanks.

regards,

-- Julien

Julien
  • 77
  • 5

1 Answers1

1

Just use the 'using' instruction

LOAD CSV  
  FROM './file.csv'
  HAVING FIELDS
  (a, b, c)
INTO postgresql:///pgloader?my_table
  TARGET COLUMNS
  (
    a,
    b,   
    c,  
    Src text using "SRC"
  )
  WITH
    skip header = 0,  
    fields optionally enclosed by '"',  
    fields escaped by double-quote,  
    fields terminated by ';'  
;
Jerome
  • 1,153
  • 1
  • 17
  • 28