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

后端 未结 5 2085
轻奢々
轻奢々 2021-02-02 12:34

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 ho

5条回答
  •  萌比男神i
    2021-02-02 12:49

    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"
    ...
    

提交回复
热议问题