How to make Postgres Copy ignore first line of large txt file How to make Postgres Copy ignore first line of large txt file sql sql

How to make Postgres Copy ignore first line of large txt file


Use HEADER option with CSV option:

\copy <table_name>  from '/source_file.csv' delimiter ',' CSV HEADER ;

HEADER Specifies that the file contains a header line with the names of each column in the file. On output, the first line contains the column names from the table, and on input, the first line is ignored. This option is allowed only when using CSV format.