More Than Five
More Than Five

Reputation: 10419

Importing a CSV file into postgres - skip the first line

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);

Upvotes: 11

Views: 14006

Answers (1)

bma
bma

Reputation: 9756

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

Upvotes: 17

Related Questions