The style for this post is tabled by Terminal CSS
⌂ Home

Importing CSVs in Postgres does not use headerinformation in csv file

The COPY command in Postgres, which can be used to import data from csv files, does not use the Headerline to assign values to columns. See Especially in cases where you have a ton of datafields in your CSV file you could avoid to specify the order in which the data is arranged, by hand.

This means that the command must have the following form

COPY <tablename>[columnvalues] FROM <csvfile> CSV HEADER;

I'm aware a small script, that generates the COPY-Command is programmed in no time. However, it seems like unnecessary work to do if postgres has already all infomation it needs in place.