Обсуждение: Wierd error for COPY command

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

Wierd error for COPY command

От
"Josh Berkus"
Дата:
Folks,

I'm getting the following error:

jwnet=# copy elbs_udf from '/home/jwnet/testtransfer/udf.txt'
jwnet-# using delimiters '|' with null as '';
": can't parse "ne 1, pg_atoi: error in "1
jwnet=#

I know from previous experience that this is a garbled error message
indicating that there is a problem on one line of the file.  However,
that particular file has 2 million lines, so finding the problem
without a line number would be nigh impossible.  The log only shows the
same error message.

Ideas, anyone?

-Josh Berkus


Re: Wierd error for COPY command

От
Tom Lane
Дата:
"Josh Berkus" <josh@agliodbs.com> writes:
> I'm getting the following error:

> jwnet=# copy elbs_udf from '/home/jwnet/testtransfer/udf.txt'
> jwnet-# using delimiters '|' with null as '';
> ": can't parse "ne 1, pg_atoi: error in "1
> jwnet=#

I'll bet your file contains \r\n newlines not \n.  The weird look
of the error comes from copy echoing the \r as part of the "data
item" it's unhappy about.  Try examining the log entry using od -c
if you want to see exactly what's there.
        regards, tom lane


Re: Wierd error for COPY command

От
"Josh Berkus"
Дата:
Tom,

> I'll bet your file contains \r\n newlines not \n.  The weird look
> of the error comes from copy echoing the \r as part of the "data
> item" it's unhappy about.  Try examining the log entry using od -c
> if you want to see exactly what's there.

Yes, you're right.  Apparently I have /r/n newlines, plus a ZL string
in the last field indicating Null.  I know that there's a command line
utility to convert DOS newlines into UNIX newlines; could anyone give
me a name?

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


Re: Wierd error for COPY command

От
"Josh Berkus"
Дата:
Tom,

> Yes, you're right.  Apparently I have /r/n newlines, plus a ZL string
> in the last field indicating Null.  I know that there's a command
> line
> utility to convert DOS newlines into UNIX newlines; could anyone give
> me a name?

Answered my own question.  The utility "dos2unix" (which is a script
file on top of "recode") is included in most Linux distributions.  It
works as follows:
either:
dos2unix filename
or:
dos2unix filename newfilename
... depending on your distro.

Thanks!

-Josh Berkus



Re: Wierd error for COPY command

От
"PG Explorer"
Дата:
need dos2unix do you?

here is a script

#!/bin/sh
tr -d '\015' < $0 > $1

chmod +x dos2unix

usage : dos2unix dosfile unixfile


http://www.pgexplorer.com

> Tom,
> 
> > Yes, you're right.  Apparently I have /r/n newlines, plus a ZL string
> > in the last field indicating Null.  I know that there's a command
> > line
> > utility to convert DOS newlines into UNIX newlines; could anyone give
> > me a name?
> 
> Answered my own question.  The utility "dos2unix" (which is a script
> file on top of "recode") is included in most Linux distributions.  It
> works as follows:
> either:
> dos2unix filename
> or:
> dos2unix filename newfilename
> ... depending on your distro.
> 
> Thanks!
> 
> -Josh Berkus
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)