My SQL script looks like below
create table "cad".yield_name
(
yield_id int primary key,
yield_name varchar,
yield_name_f varchar
);
copy cad.yield_name
from '/data/cad/base/YIELD\ NAME.csv'
delimiter ',' csv header;
As you see, I am importing a file called '/data/cad/base/YIELD\ NAME.csv'
, which is available in the directory when I do ls -ltr
.
total 30724
-rw-r--r-- 1 postgres postgres 578264 Aug 31 2015 CONVERSION FACTOR.csv
-rw-r--r-- 1 postgres postgres 1155 Aug 31 2015 FOOD GROUP.csv
-rw-r--r-- 1 postgres postgres 761846 Aug 31 2015 FOOD NAME.csv
-rw-r--r-- 1 postgres postgres 2850 Aug 31 2015 FOOD SOURCE.csv
-rw-r--r-- 1 postgres postgres 12740 Aug 31 2015 NUTRIENT NAME.csv
-rw-r--r-- 1 postgres postgres 2229 Aug 31 2015 NUTRIENT SOURCE.csv
-rw-r--r-- 1 postgres postgres 162305 Aug 31 2015 REFUSE AMOUNT.csv
-rw-r--r-- 1 postgres postgres 4196317 Aug 31 2015 REFUSE NAME.csv
-rw-r--r-- 1 postgres postgres 4193826 Aug 31 2015 YIELD NAME.csv
-rw-r--r-- 1 postgres postgres 1665394 Sep 21 2015 CNF 2015 users_guide EN.pdf
-rw-r--r-- 1 postgres postgres 1637393 Sep 21 2015 CNF 2015 users_guide FR.pdf
-rw-r--r-- 1 postgres postgres 893270 Sep 21 2015 CNF 2015 Database structure EN .pdf
-rw-r--r-- 1 postgres postgres 972920 Sep 21 2015 CNF 2015 database structure FR .pdf
-rw-r--r-- 1 postgres postgres 50521 Oct 6 2015 MEASURE NAME.csv
-rw-r--r-- 1 postgres postgres 40265 Oct 9 2015 YIELD AMOUNT.csv
-rw-r--r-- 1 postgres postgres 16257583 Oct 30 2015 NUTRIENT AMOUNT.csv
However, when I try to import, I get the following error on the command-line
2021-11-30 00:24:49.736 UTC [55] STATEMENT: copy cad.yield_name
from '/data/cad/base/YIELD\ NAME.csv'
delimiter ',' csv header;
psql:sql/postgres/cad/base/1_yield_name.sql:10: ERROR: could not open file "/data/cad/base/YIELD\ NAME.csv" for reading: No such file or directory
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
I am using PostgreSQL 14.1
docker image on Mac OSX.
Could someone help me understand how can I import the file name with space using copy
command?
Thank you