使用python在mapper和reducer中出错

时间:2014-05-24 21:13:03

标签: python-2.7 hadoop amazon-s3 mapreduce

我在群集中运行mapper.py文件时出现问题。错误是"行"之前的意外语法在" strl = line.strip()"。 我在本地测试时没有错误。我希望保存文本文件的文字并更改其格式并计算它们并发送到s3桶中的输出。

指导最受欢迎。感谢

映射器:

import sys, re

for line in sys.stdin:
strl = line.strip()
words = strl.split()
for word in words:
    word = word.lower()
    result = ""
    charref = re.compile("[a-f]")
    match = charref.search(word[0])
    if match:
        result+= "TR2234J"
    else:
        result+= ""
    print result, "\t"

减速器:

import sys

for line in sys.stdin:
    line = line.strip()
    new_word =""
    words = line.split("\t")
    final_count = len(words)
    my_num = final_count / 6
    for i in range (my_num):
        new_word = "".join(words[i*6:10+(i*6)])
        print new_word, "\t"

0 个答案:

没有答案
相关问题