RE: unable to read composite types from CSV files

From: "Ian Bell" <ib(at)ianbellsoftware(dot)com>
To: "'David G(dot) Johnston'" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "'pgsql-novice'" <pgsql-novice(at)postgresql(dot)org>
Subject: RE: unable to read composite types from CSV files
Date: 2018-04-20 00:56:33
Message-ID: !&!AAAAAAAAAAAYAAAAAAAAADldbAmb6+pIq6nH7MxZl07CgAAAEAAAADAjdnUJ3pxGts1oN4KodRUBAAAAAA==@ianbellsoftware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello David,

Bingo! I changed the CSV file to the following and it works!

"(1, 2, 3)"

"(4, 5, 6)"

"(7, 8, 9)"

If you don’t mind, could you point out the section in the PostgreSql manual/documentation where this is discussed/explained. I have repeatedly read section 8.16.6 (i.e. Composite Type Input and Output Syntax) but it does not appear to include this detail.

I spent the whole day struggling with this problem and I am very much relieved that you were able to offer a solution so quickly. A big thanks!

Ian

From: David G. Johnston [mailto:david(dot)g(dot)johnston(at)gmail(dot)com]
Sent: 19 April, 2018 20:34
To: ib(at)ianbellsoftware(dot)com
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: unable to read composite types from CSV files

On Thursday, April 19, 2018, Ian Bell <ib(at)ianbellsoftware(dot)com <mailto:ib(at)ianbellsoftware(dot)com> > wrote:

2) If composite types can indeed be read/imported from CSV files then would you please take a look at the sample code/data provided below and tell me why it generates the error message ‘extra data after last expected column’. In other words, what am I doing wrong?

Test CSV file contents

The contents of the CSV file (i.e. ‘testComposite.csv’) is:

(1,2,3)

(4,5,6)

(7,8,9)

Your csv data contains commas. In order to treat them as data instead of structure you have to double-quote the field/value containing the affected data.

David J.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2018-04-20 01:17:30 Re: unable to read composite types from CSV files
Previous Message David G. Johnston 2018-04-20 00:34:08 Re: unable to read composite types from CSV files