Redis-cli --csv option (exporting to csv)

The command:

redis-cli --csv hgetall mykey > stdout.csv

created a CSV file like:

"id","value","id","value", ...

To make life easier, I used:

sed -i 's/\([^\",]*",[^,]*\),/\1\n/g' stdout.csv

which converted the output into:

"id", "value"
"id", "value"
"id", "value"
...

Cutting edge!

I've just looked at the source code & all it does is output the commands as comma separated values to stdout. Which is no big surprise.

So you could just redirect it to a file, in the standard way, as long as you're on Linux?

e.g./

redis-cli --csv your-command > stdout.csv 2> stderr.txt

Tags:

Redis