![]() ![]() ![]() This should not break anything the HEADER directive only ever tells pg to skip reading one line, the actual data is always imported using column order specified in the COPY statement, or the table's column order if the COPY did not specify it. Let us take a look at the following images to understand the functionality. Note that there's no HEADER modifier on the copy statement this because -n 2 on the tail command will always start at line #2 of each file it outputs. PgAdmin supports import/export of a table to/from a csv file via its interface. Parse it from within the INSERT / UPDATE using something that can process a CSV-row (suggest TextCSV::XS ). ) FROM tbl' in a call to COPY FROM STDIN and make use of it. Testdb=# copy tt from program 'tail -quiet -n 2 /tmp/so_267604/*.csv' csv Wrap a psql -d myDb -c 'SELECT convertfrom (col. Testdb=# create table tt(cola text, colb text) Sh-5.0$ echo -e "cola,colb\naval3,bval3\naval4,bval4" > second.csv Sh-5.0$ echo -e "cola,colb\naval1,bval1\naval2,bval2" > first.csv Step 3: Click on your tablename in pgadmin you will see an option for import/export. I would recommend creating columns using the dashboard. Here's a trivial example: sh-5.0$ mkdir /tmp/so_267604/ Step 2: Create the exact number of columns present in the CSV file. Unfortunately I only have a linux env so I can't give you a command/statement that will work for your case, but hopefully this gives you the idea and/or is useful for someone else.ĬOPY FROM with a file can only support one file at a time, but being a bit clever with a COPY FROM PROGRAM is one way of importing multiple files with one COPY. Peter's answer is probably the way to go, but wanted to chime in with another approach using COPY FROM PROGRAM. ![]()
0 Comments
Leave a Reply. |