Обсуждение: Problem with COPY

Поиск
Список
Период
Сортировка

Problem with COPY

От
Brauner Oliveira
Дата:
Hello,

I am trying to copy a table from a file:

COPY table FROM 'file/path/filename.csv' DELIMITER ';' CSV;

But I got this error:

ERROR: value too long for type character varying(8)
SQL state: 22001
Context: COPY $tablename, line 1, column $colum_name: "69900900"

Look that the length of the data (69900900) i want to copy fits the column data type (varchar(8)). The length is exactly the same.

The file is well formatted and Encoded in UTF-8:

value1;value2;value3;value4

Someone know what i'm doing wrong?

Thank you.

Re: Problem with COPY

От
Tom Lane
Дата:
Brauner Oliveira <brauner.rno@gmail.com> writes:
> ERROR: value too long for type character varying(8)
> SQL state: 22001
> Context: COPY $tablename, line 1, column $colum_name: "69900900"

Is that the first field of the first line?

> The file is well formatted and Encoded in UTF-8:

I'm suspicious that you prepared the file in some text editor that
"helpfully" inserted an invisible BOM (byte order mark) character at the
start of the file.  Windows editors in particular seem to think this is
a good idea.

            regards, tom lane


Re: Problem with COPY

От
Brauner Oliveira
Дата:
I used Notepad++ and converted the file to UTF-8. But, there's an option to "Convert to UTF-8 without BOM". This time, i used it and worked.

Thank you.

2013/7/3 Tom Lane <tgl@sss.pgh.pa.us>
Brauner Oliveira <brauner.rno@gmail.com> writes:
> ERROR: value too long for type character varying(8)
> SQL state: 22001
> Context: COPY $tablename, line 1, column $colum_name: "69900900"

Is that the first field of the first line?

> The file is well formatted and Encoded in UTF-8:

I'm suspicious that you prepared the file in some text editor that
"helpfully" inserted an invisible BOM (byte order mark) character at the
start of the file.  Windows editors in particular seem to think this is
a good idea.

                        regards, tom lane