把csv数据导入redis的示例:
通过执行以下代码程序把csv数据导入redis。
import csv
import redis
r = redis.StrictRedis(host='47.115.124.39', port=6379, db=1, password='123456')
with open('tets.csv', 'rt', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
name = row['name']
id = row['id']
print(row)
r.set(name,id) #将内容写入redis
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!