LOAD a CSV

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)

Answers

  • 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 ....

  • I run this in linux

  • 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)
    
    
  • please , can you tell me how can I access to this directory: $ vsql -c ,

  • Jim_KnicelyJim_Knicely Administrator

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

  • 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?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.