I have a series of CSV files, in the format:
"Alice","Bob","A",123.46,"4"
"Charlie","Dana","B",987.6543,"9"
...
I want to produce a table like this:
id file_id mch c1 c2 c3 c4 c5
--- ------- ----- --------- ------ --- -------- ---
1 462 FALSE 'Alice' 'Bob' 'A' 123.46 '4'
2 462 FALSE 'Charlie' 'Dana' 'B' 987.6543 '9'
... 462 FALSE ... ... ... ... ...
... ... ... ... ... ... ... ...
where
idis the primary key, is arbitrary, and should be automatically generated in order of insertion. It's specified as such.file_idis constant per file that I want to insert to this table, though varies between files. It is known before I try to bulk-add the file.mchis always false, at time of insertionc1throughc5are generic column titles, with types known in advance.
Currently I'm using the following SQL command to bulk-insert each of my CSV files:
COPY pos(c1,c2,c3,c4,c5)
FROM 'C:/Users/.../filename.csv'
WITH (FORMAT CSV, HEADER FALSE, ENCODING 'UTF8')
which works for filling the primary key id. This produces a table without the columns file_id or mch.
But I can't figure out how to properly populate the other two columns (file_id and mch) within the same statement, without doing a whole other UPDATE statement.