COPY FROM file error: could not open file ... for reading: No such file or directory

From: Ryszard Czermiński <ryszard(at)czerminski(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: COPY FROM file error: could not open file ... for reading: No such file or directory
Date: 2014-06-04 16:03:13
Message-ID: CANS_SThtR_sqPUj-FXqND89=m3sLy1PXZe17-4no_DRg6RWvQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I am trying to import data from csv file to a table, but COPY command
fails with "No such file or directory" error message - despite the fact
that the file I am trying to read is definitely there. See below.

Apparently (as a novice :) I am missing something - your help will be
highly appreciated.

Best regards,
Ryszard

$ more import_from_csv.sql
CREATE TABLE addr
(STREET varchar, CITY varchar, STATE char(2), ZIP char(10));
COPY addr FROM 'addr.csv' DELIMITER ',' CSV;
$ psql -U postgres -c 'drop table addr'
DROP TABLE
$ wc -l addr.csv
2 addr.csv
$ psql -U postgres -f import_from_csv.sql
CREATE TABLE
*psql:import_from_csv.sql:3: ERROR: could not open file "addr.csv" for
reading: No such file or directory*
$ psql --version
psql (PostgreSQL) 9.3.4
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
$

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Szymon Guz 2014-06-04 16:09:35 Re: COPY FROM file error: could not open file ... for reading: No such file or directory
Previous Message lmanorders 2014-06-03 00:19:45 Re: INSERT INTO FROM SELECT