mapper.
py
#!/usr/bin/env python
import sys
for line in [Link]: # Read input from STDIN (standard input)
line = [Link]() # Remove any leading/trailing whitespace
sensor_id, date, hour, temperature = [Link](",") # Split the line into
sensor_Id, date, hour, temperature
print("{0}\t{1}".format(date, temperature)) # Emit the date as the key and
temperature as the value
----------------------------
[Link]
#!/usr/bin/env python
import sys
# Initialize variables to store the current date and the maximum temperature
current_date = None
max_temperature = -float("inf")
for line in [Link]: # Read input from STDIN (standard input)
line = [Link]() # Remove any leading/trailing whitespace
date, temperature = [Link]("\t") # Parse the input we got from the mapper
temperature = float(temperature)
if current_date == date: # Check if we are still processing the same date
if temperature > max_temperature: # Update the maximum temperature for the
current date
max_temperature = temperature
else:
if current_date: # If the date changes and it's not the first line
print("{0}\t{1}".format(current_date, max_temperature)) # Emit the
maximum temperature for the previous date
current_date = date # Update to the new date
max_temperature = temperature
if current_date: # Output the maximum temperature for the last date
print("{0}\t{1}".format(current_date, max_temperature))