How to import a csv file with a header into a PostgreSQL table

13 September,2019 by Rambler

Question: How can I import a  csv file with the first row having the column names? I want to disregard the first line 

Answer: Use the HEADER parameter. The HEADER parameter according to the documentation "Specifies that the file contains a header line with the names of each column in the file" 

This is an example of a COPY which  copies the data from the csv file into the table. The HEADER parameter will force the COPY action to disregard the fist line on input 

COPY myschema.myTable(col1,col2,col3) FROM '/tmp/myfile1.csv' DELIMITER ',' CSV HEADER;

Author: Rambler (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to import a csv file with a header into a PostgreSQL table