Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing a CSV file into postgres - skip the first line

Tags:

postgresql

How do I import a CSV file into postgres and make it skip the first line (it's just column titles).

I try:

\COPY products(sight, department) from 'coy.csv' with (FORMAT CSV);
like image 832
More Than Five Avatar asked Aug 29 '13 15:08

More Than Five


1 Answers

Adding the HEADER line will account for the first line being column headers.

COPY products (sight,department) FROM 'coy.csv' CSV HEADER;

http://www.postgresql.org/docs/current/static/sql-copy.html

like image 83
bma Avatar answered Nov 12 '22 16:11

bma