Re: [GENERAL] import CSV file to a table - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] import CSV file to a table
Date
Msg-id CAKFQuwbur63EfDN=rf6S_DKUVgyHrEp9yMJmovTQDCWkyEeJ8w@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] import CSV file to a table  (Karl Czajkowski <karlcz@isi.edu>)
List pgsql-general
On Wed, Mar 8, 2017 at 9:13 AM, Karl Czajkowski <karlcz@isi.edu> wrote:

With the temporary table, you can use SQL for most validation or data
interrogation, but you need to know at least enough schema information
in advance to form the COPY statement. Parsing the CSV header row to
plan your work puts you right back to requiring a robust CSV parser
unless you can constrain your input scenarios to only handle very
trivial headers.

​You can write the entire contents of the CSV into a psql variable and process the text blob from there using intermediate arrays.

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] Unable to start postgresql
Next
From: Rob Sargent
Date:
Subject: Re: [GENERAL] import CSV file to a table