Lists: | pdxpug |
---|
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pdxpug(at)postgresql(dot)org |
Subject: | COPY command syntax error |
Date: | 2011-02-02 19:19:44 |
Message-ID: | alpine.LNX.2.00.1102021113280.4447@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
I'm trying to import data from a .csv file into an existing table. It
worked the first time I loaded data into this table.
I'm invoking psql from the same directory as the import.csv file. The command I'm using,
and the results are:
jerrittwq=# copy monitor from
'/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv'
with delimiter as ':' csv;
ERROR: could not open file
"/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv"
for reading: No such file or directory
Doesn't matter how I specify the file's location (full path or cwd). Do I
also need to specify the text delimeters with quote as '''? (The command
line does not like my using double quotes to delimit the single quote.)
What do I have syntactically wrong here?
Rich
From: | Darrell Fuhriman <darrell(at)garnix(dot)org> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:23:15 |
Message-ID: | 36423DC3-08F2-45E5-8BFF-40D39AFE10B7@garnix.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
>
> What do I have syntactically wrong here?
I think you want to add a backslash in front of that "copy."
d.
From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:23:47 |
Message-ID: | 1296674627.18411.55.camel@jd-desktop |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, 2011-02-02 at 11:19 -0800, Rich Shepard wrote:
> I'm trying to import data from a .csv file into an existing table. It
> worked the first time I loaded data into this table.
>
> I'm invoking psql from the same directory as the import.csv file. The command I'm using,
> and the results are:
>
> jerrittwq=# copy monitor from
> '/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv'
> with delimiter as ':' csv;
> ERROR: could not open file
> "/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv"
> for reading: No such file or directory
>
> Doesn't matter how I specify the file's location (full path or cwd). Do I
> also need to specify the text delimeters with quote as '''? (The command
> line does not like my using double quotes to delimit the single quote.)
>
> What do I have syntactically wrong here?
Is the file readable by the user that runs the postgresql daemon? (the
complete path)
JD
>
> Rich
>
--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:28:11 |
Message-ID: | alpine.LNX.2.00.1102021127470.4447@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, 2 Feb 2011, Joshua D. Drake wrote:
> Is the file readable by the user that runs the postgresql daemon? (the
> complete path)
Josh,
It is now; makes no difference.
Rich
From: | gabrielle <gorthx(at)gmail(dot)com> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:31:07 |
Message-ID: | AANLkTik2o89K4AbwcA5MZfACJjnbavC_SJhm3kEXWww2@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, Feb 2, 2011 at 11:19 AM, Rich Shepard <rshepard(at)appl-ecosys(dot)com> wrote:
> I'm trying to import data from a .csv file into an existing table. It
> worked the first time I loaded data into this table.
>
> I'm invoking psql from the same directory as the import.csv file. The
> command I'm using,
> and the results are:
>
> jerrittwq=# copy monitor from
> '/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv'
> with delimiter as ':' csv;
> ERROR: could not open file
> "/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv"
> for reading: No such file or directory
>
> Doesn't matter how I specify the file's location (full path or cwd). Do I
> also need to specify the text delimeters with quote as '''? (The command
> line does not like my using double quotes to delimit the single quote.)
>
> What do I have syntactically wrong here?
That syntax (COPY table FROM '/path/to/file' WITH DELIMITER AS ':'
CSV;) works for me in a similar test.
Are you sure the file exists? Try taking off the "with ... csv" piece
and see if you get the same error.
gabrielle
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:31:41 |
Message-ID: | alpine.LNX.2.00.1102021128150.4447@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, 2 Feb 2011, Darrell Fuhriman wrote:
> I think you want to add a backslash in front of that "copy."
Darrell,
I thought that 'copy' and '\c' were equivalent. The postgres docs show
examples using copy and not the psql \c.
Regardless, when I try \c I get a port warning and no data added:
jerrittwq=# \c monitor from
'/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv'
with delimiter as ':' csv;
invalid port number: "with"
Previous connection kept
Thanks,
Rich
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:35:56 |
Message-ID: | alpine.LNX.2.00.1102021133450.4447@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, 2 Feb 2011, gabrielle wrote:
> That syntax (COPY table FROM '/path/to/file' WITH DELIMITER AS ':'
> CSV;) works for me in a similar test.
Gabrielle,
Worked for me, too, a couple of days ago when I first created the database
and table.
> Are you sure the file exists? Try taking off the "with ... csv" piece
> and see if you get the same error.
Yes it exists:
[rshepard(at)salmo
~/projects/nevada/queenstake/permitwatch/water-quality-info/csv_versions]$
ll import.csv
-rw-r--r-- 1 rshepard users 227399 2011-02-02 10:45 import.csv
And the psql result:
jerrittwq=# copy monitor from
'/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv';
ERROR: could not open file
"/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv"
for reading: No such file or directory
Thanks,
Rich
From: | Darrell Fuhriman <darrell(at)garnix(dot)org> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:35:58 |
Message-ID: | B660C5B3-95E2-491B-8A27-5EB0AD54F0BD@garnix.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
>
> Regardless, when I try \c I get a port warning and no data added:
\c is not short for "copy" it's short for "connect" That's why you're getting the error.
COPY (without the backslash) only works the file is directly accessible by the postgres process on the server. \copy allows you to get the same functionality using any file the *client* has access to. They're very different things.
d.
From: | Tim <tim-pdxlug(at)sentinelchicken(dot)org> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:38:28 |
Message-ID: | 20110202193828.GT2121@sentinelchicken.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
> Yes it exists:
>
> [rshepard(at)salmo
> ~/projects/nevada/queenstake/permitwatch/water-quality-info/csv_versions]$>
> ERROR: could not open file
> "/home/rshepard/projects/queenstake/permitwatch/water-quality-info/csv_versions/import.csv"
> for reading: No such file or directory
Uh... I see a difference in paths there.
"/home/rshepard/projects/nevada" != "/home/rshepard/projects/queenstake"
Unless you have a goofy symlink thing going on...
tim
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error |
Date: | 2011-02-02 19:39:40 |
Message-ID: | alpine.LNX.2.00.1102021139010.4447@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, 2 Feb 2011, Darrell Fuhriman wrote:
> \c is not short for "copy" it's short for "connect" That's why you're getting the error.
Ah, I miss-read the command.
> COPY (without the backslash) only works the file is directly accessible by
> the postgres process on the server. \copy allows you to get the same
> functionality using any file the *client* has access to. They're very
> different things.
Server and client are on the same host here.
Rich
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pdxpug(at)postgresql(dot)org |
Subject: | Re: COPY command syntax error [SOLVED] |
Date: | 2011-02-02 19:44:28 |
Message-ID: | alpine.LNX.2.00.1102021143310.4447@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pdxpug |
On Wed, 2 Feb 2011, Tim wrote:
> Uh... I see a difference in paths there.
>
> "/home/rshepard/projects/nevada" != "/home/rshepard/projects/queenstake"
Thanks, Tim. Brent pointed this out, too. I didn't see that I dropped a
directory in the path. That's where other eyeballs come in very handy.
Rich