I would like to export a subset of my Redis data on the slave to a csv file. I notice a new csv output option was added to redis-cli but I am unable to find documentation of how it works. Enabling the option prints the command outputs to screen in csv format. What is the best way to get this into a csv file?
5 Answers
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
2 Comments
Mithril
how to import the exported csv?
PAA
@Boom Shakalaka - Please guide us here: stackoverflow.com/questions/53321019/…
If you don't require wrapping the values in quotes as --csv does, then the raw output is sufficient, and you just need to join every 2 lines with a comma to get a CSV:
redis-cli <your redis command> | paste -d "," - - > out.csv
1 Comment
steamdragon
This is the best answer IMO