Mapper program : temperature_mapper.py #!/usr/bin/env python import sys # input comes from standard input STDIN year=0; for data in sys.stdin: data = data.strip() #remove leading and trailing whitespaces yearData = data.split(',') #split the line into words and returns as a list year = yearData[0]; temperature_data=yearData[1:13] print('%s %s' % (year, temperature_data)) #write the results to standard output STDOUT Reducer program: temperature_reducer.py #!/usr/bin/env python from operator import itemgetter import sys import ast # input comes from STDIN for line in sys.stdin: line = line.strip() new_year, new_temperature = line.split(' ',1) list = ast.literal_eval(new_temperature) #Convert string to list try: new_year = int(new_year) except ValueError: continue print("%s\t%s"%(new_year,max(list))) Reducer program : "reducer.py" #!/usr/bin/env python from operator import itemgetter import sys # using a dictionary to map words to their counts current_word = None current_count = 0 word = None # input comes from STDIN for line in sys.stdin: line = line.strip() word, count = line.split(' ',1) try: count = int(count) except ValueError: continue if current_word == word: current_count += count else: if current_word: print ('%s\t%s'%(current_word, current_count)) current_count = count current_word = word if current_word == word: print ('%s\t%s'%(current_word,current_count)) Mapper program mapper.py #!/usr/bin/env python import sys #Word Count Example # input comes from standard input STDIN for data in sys.stdin: data = data.strip() #remove leading and trailing whitespaces lines = data.split() #split the line into words and returns as a list for word in lines: #write the results to standard output STDOUT print('%s %s' % (word, 1))