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

后端 未结 1 388
-上瘾入骨i
-上瘾入骨i 2021-02-02 07:14

I have a fairly large .txt file ~9gb and I will like to load this txt file into postgres. The first row is the header, followed by all the data. If I postgres COPY the data dire

相关标签:
1条回答
  • 2021-02-02 07:53

    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.

    0 讨论(0)
提交回复
热议问题