【发布时间】:2020-06-29 06:11:53
【问题描述】:
目前,我有一个 user_follower.csv 例如:
user follower
a b
a c
a b
b a
b c
我正在尝试执行 mapreduce,在应用 mapreduce 后,我可以得到如下输出:
user follower counts
a b 2
a c 1
b a 1
b c 1
我是一个使用 mapreduce 概念并在命令行中用 vim 编写 python 脚本的初学者。这是我必须得到的输出,但是得到了ValueError: too many values to unpack
import sys
from collections import Counter
counts= Counter('user')
for line in sys.stdin:
data = line.strip()
user, follower = data
counts[line] += 1
sys.stdout.write("{0}\t{1}\t{2}\n".format(user,follower,counts))
任何帮助或建议将不胜感激。
【问题讨论】: