0

I'd like to copy from with csv file with Postgres.

That csv file has array literal whose delimiter is ;.

example: a,b,c,{1;2;3}

I did that with replacing delimiter of csv file , to | and set option delimiter | and replacing delimiter of array literal ; to ,.

example: a|b|c|{1,2,3}

I think there may be option to set delimiter of array literal.
If so, I don't have to replace delimiter of csv file.

Are there any smarter way?

kiitosu
  • 117
  • 12
  • Check this post [How to import CSV file data into a PostgreSQL table?](https://stackoverflow.com/questions/32607318/export-an-array-into-a-csv-file-in-pl-pgsql) – cabesuon Jan 27 '20 at 01:57

1 Answers1

1

There is no option to configure the separator between the elements of an array in its text representation.

But if you have any control over how the CSV file is generated, you can escape the array literal:

a,b,c,"{1,2,3}"

That would work fine with COPY.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263