Import .csv file into cassandra

11,073

Solution 1

table.csv file should be in cassandra installation directory(where you run cqlsh).

File name is case senstive, so check with orginal file name case.

Solution 2

make sure your local directory should be same and there also same file put up.

cqlsh.bat 192.168.1.xx -k [keyspace name] -e "COPY [domain] FROM 'filename' WITH HEADER=true"
Share:
11,073
Anse danesh
Author by

Anse danesh

Updated on June 25, 2022

Comments

  • Anse danesh
    Anse danesh almost 2 years

    I want to import a CSV file into cassandra. When I write this command on cassandra cqlsh, I got an error: command is:

    COPY table ( ID,  name) FROM 'table.csv' WITH HEADER = TRUE;
    

    and the error:

    Can't open 'table.csv' for reading: [Errno 2] No such file or directory: 'table.csv'
    

    Can any one tell me what does it mean?

    • keelar
      keelar almost 11 years
      Did you run cqlsh in the same directory as where your 'table.csv' reside?
    • Anse danesh
      Anse danesh almost 11 years
      yes. my 'table.csv' is in cassandra/bin directory where cqlsh is. is there any deferences between windows .csv file and cassandra's? my 'table.csv' file was a export from windows mysql table.
    • keelar
      keelar almost 11 years
      I am saying did you run cqlsh in the same directory as your file? Since you are able to run cqlsh in directories other than cassandra/bin.
    • Anse danesh
      Anse danesh almost 11 years
      yes. I think I run cqlsh file in the same directiry as my .csv file.
    • Anse danesh
      Anse danesh almost 11 years
      it works.. thanks in advance..
  • Revolucion for Monica
    Revolucion for Monica over 6 years
    How would you do if copying several columns of a file with countless of them ?