user2393183
user2393183

Reputation:

Trying to copy text file to table postgresql

Trying to save a text file from desktop

copy my_notes(notes) from  '/root/desktop/test_note.txt' 

It shows this error..

ERROR: extra data after last expected column

CONTEXT: COPY my_notes, line 3: " cher"

I'm a newbie in postgresql

Upvotes: 0

Views: 159

Answers (2)

Erwin Brandstetter
Erwin Brandstetter

Reputation: 658102

To read a plain text from a file, there is also pg_read_file() - reserved for superusers, though, because of potential security implications. Details in this related answer:
Read data from a text file inside a trigger

Upvotes: 0

Craig Ringer
Craig Ringer

Reputation: 324771

COPY expects tab-separated data, with newlines separating rows.

It isn't suitable for just loading a text file into a field. To do that, I suggest using a simple script, say python and psycopg2.

Upvotes: 2

Related Questions