Load CSV file in Redis using Redis-cli of Windows version?

别来无恙 提交于 2019-12-07 00:51:43

For instance when you use mentioned "Git Bash" you can do as follows (last step outputs the commands, but they may as well be piped to redis-cli:

The above comes from Git 2.17.1 for Windows. The final command-line is:

tail -n +2 test.csv | awk -F',' '{print "SET \""$1"\" \""$0"\""}' | redis-cli

Please note a couple of assumptions:

  • Strings in CSV are not enclosed in double quotes - if so you'd have to escape them when outputting "SET" commands
  • First line in CSV contains headers and values are separated with a comma.

Just click GO! FastoRedis can do it more simple than redis-cli.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!