Jean
Jean

Reputation: 621

Cassandra CQLSH COPY FROM CSV: Can I create my own colum from others

I often use the cqlsh command COPY...FROM CSV... but I have new needs. I'd like to add an extra colum in my cassandra table that would be created from two other columns.

Example (cvs file)

1;2
2;4
3;6

would become a table with these values:

my table: 12;1;2 24;2;4 36;3;6

I ve used other options but they're much slower than COPY...FROM CSV

Do you know if I can do that using COPY...FROM CSV?

Upvotes: 0

Views: 282

Answers (1)

Ashraful Islam
Ashraful Islam

Reputation: 12830

You can't do this with only copy command.

If you are using Linux then

First dumb the csv to file with copy command let's say csv_test.csv

1;2
2;4
3;6

Then use the below command to combine first two column into one.

cat csv_test.csv | awk -F ";" '{print $1$2 ";" $0}' > csv_test_combine.csv

Output file csv_test_combine.csv :

12;1;2
24;2;4
36;3;6

Upvotes: 1

Related Questions