Skip to main content
Question

LOAD a CSV

  • July 23, 2020
  • 6 replies
  • 9 views

yeifer

I have a problem when I want to load one .csv file, I did this
STEP 1
create table prueba(Id VARCHAR(100),Sepal_Length FLOAT,Sepal_Width FLOAT,Petal_Length FLOAT,Petal_Width FLOAT,Species VARCHAR(100));

STEP 2
COPY iris(Id,Sepal_Length, Sepal_Width,Petal_Length, Petal_Width,Species) FROM LOCAL 'C:\home\dbadmin\Documents\data\prueba.csv' WITH DELIMITER ',';

RESULT
ERROR 5783: Client error: Could not open file [\home\dbadmin\Documents\data\prueba.csv] for reading (in function statFiles() at Bulkload.cpp:338)

6 replies

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • July 23, 2020

Are you reading from a Windows client?
I think you have to double the backslashes - let me try ...

C:\Users\gessnerm\sql>type C:\Users\gessnerm\sql\inp.csv
id,nm
42,arthur
43,ford
C:\Users\gessnerm\sql>vsql -c "create table inp(id int not null,nm varchar(32))"
CREATE TABLE

C:\Users\gessnerm\sql>vsql -c "COPY inp FROM LOCAL 'C:\\Users\\gessnerm\\sql\\inp.csv' DELIMITER ',' SKIP 1"
 Rows Loaded
-------------
           2
(1 row)

Works as I had expected ....


yeifer
  • Author
  • New Participant
  • July 23, 2020

I run this in linux


marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • July 23, 2020

Then - just stick to the way file paths are used in Linux ...

$ cat /home/gessnerm/1/Vertica/data/inp.csv
id,nm
42,Arthur
43,Ford
$ vsql -c "COPY inp FROM LOCAL '/home/gessnerm/1/Vertica/data/inp.csv' DELIMITER ',' SKIP 1"
 Rows Loaded 
-------------
           2
(1 row)


yeifer
  • Author
  • New Participant
  • August 3, 2020

please , can you tell me how can I access to this directory: $ vsql -c ,


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • August 3, 2020

@yeifer - Your posts seeme to be missing some content. Could you repost?


marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • August 3, 2020

Well, you wrote'C:\home\dbadmin\Documents\data\prueba.csv' for the file name.

On Linux, you would have to write : '/home/dbadmin/Documents/data/prueba.csv'.

Or did you mean something else?