0
votes

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?

1
COPY command won't handle that operation. You can do data wrangling on the existing csv to create new columns. And then use the copy command. - Bigby

1 Answers

1
votes

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