I want to import content of CSV file to a table via bash script without creating temporary table and I also want to skip some columns in CSV file (for instance, CSV file has 12 column and main table has only 2 column, If possible I would use only 2 column in CSV file) Is there any way to do it?
Regards,
--
Gunce Kaya
Not too difficult, but "unusual". However, there is a restriction that the data cannot have an embedded comma. That is, you can't have something like: "a,b",c and want two columns with a,b and c as the values.
[tsh009@it-johnmckown-linux junk]$ cat ptest.csv
a,b,c,d,e,f,g,h,i
1,2,3,4,5,6,7,8,9
z,y,x,w,v,u,t,s,r,q
[tsh009@it-johnmckown-linux junk]$ cat ptest.sh
#!/bin/bash
printf "%s\n" 'COPY schema1.table1(column1from5, column2from7) FROM stdin;'