Created
August 25, 2023 20:32
-
-
Save schutt/9f2ba145c85878e76588af0f4d013b80 to your computer and use it in GitHub Desktop.
Cassandra cqlsh query output to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Cassandra cqlsh output is pipe delimited, it is useful to directly pipe query results to CSV instead. | |
if [ -p /dev/stdin ]; then | |
sed 's/\ //g; /^----.*/d; /^(/d; /^\s*$/d; s/|/,/g;' | |
else | |
echo "No input on stdin." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been using
sed
script in thiszsh
script for quick test queries for years. It has been so long that I don't remember if I wrote the regular expressions or borrowed them.