I have installed Cassandra-2.2.7 and it's working fine. I have created a table with schema
create table student(name text,id int primary key,age int,branch text);
with id being primary key. I have a CSV file with the headers (name,id,age,branch) which I want to import into this table. The CSV file contains some 3000 rows. Now when I try the import command,
copy students from 'students.csv' with HEADER=TRUE;
It shows error, invalid literal for int() with base 10
.
When I did select * from student;
command, the schema is as follows,
id,age,branch,name
The table columns have somehow changed to alphabetic wise. As id
is the primary key, it remained as first column. How can I import the data to the table?
You can specify the order of the columns in the CSV file when running the copy command:
copy students (name, id, age, branch) from 'students.csv' with HEADER=TRUE;