Table columns:
col1, col2, col3, fname, lname
CSV file contains values like:
col1,col2,col3
val1,val2,val3
val1,val2,val3
I want to add data from csv along with additional data i.e. col1,col2,col3,fname,lname
in table using COPY functionality of postgres.
Can this be done using COPY? If not please suggest workaround.
psql \COPY supports reading from program output. We can modify the file on the fly using cat and sed:
'cat myFile | sed \'s/$/;col1;col2/\''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With