I\'m new in cassandra, and I have to export the result of a specific query to a csv file.
I found the COPY
command, but (from what I understand) it allo
With bash:
If you need to query the data (not possible with COPY TO) and if you need the final product to be importable (ie with COPY FROM):
cqlsh -e "SELECT * FROM bar WHERE column = 'baz' > raw_output.txt
Then you can reformat the output with sed
sed 's/\ //g; /^----.*/d; /^(/d; /^\s*$/d;' raw_output.txt | tee clean_output.csv
Which pretty much says
sed 'remove spaces; remove the column boarder; remove lines beginning with (COUNT X); and remove blank lines' | write output into clean_output.csv
The sed regexp's could be cleaned up to better suite your specific case, but thats the general idea.