LOAD a CSV

yeiferyeifer Community Edition User

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

  • marcothesanemarcothesane - Select Field - Administrator

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

  • yeiferyeifer Community Edition User

    I run this in linux

  • marcothesanemarcothesane - Select Field - Administrator

    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)
    
    
  • yeiferyeifer Community Edition User

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

  • Jim_KnicelyJim_Knicely - Select Field - Administrator

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

  • marcothesanemarcothesane - Select Field - Administrator

    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