【发布时间】:2015-01-06 08:45:09
【问题描述】:
每当我尝试在 Hadoop 系统中运行 Reducer python 程序时,我都会收到此错误。 Mapper 程序虽然运行良好。已授予与我的 Mapper 程序相同的权限。有语法错误吗?
Traceback(最近一次调用最后一次): 文件“reducer.py”,第 13 行,在 word, count = line.split('\t', 1) ValueError: 需要超过 1 个值才能解压
#!/usr/bin/env python
import sys
# maps words to their counts
word2count = {}
# input comes from STDIN
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# parse the input we got from mapper.py
word, count = line.split('\t', 1)
# convert count (currently a string) to int
try:
count = int(count)
except ValueError:
continue
try:
word2count[word] = word2count[word]+count
except:
word2count[word] = count
# write the tuples to stdout
# Note: they are unsorted
for word in word2count.keys():
print '%s\t%s'% ( word, word2count[word] )
【问题讨论】: