Source

data_munging_code_kata / weather / temp_spread.py

Full commit
import math


class TemperatureSpread:

	def __init__(self):
		self.min_spread = None
		self.min_spread_day = None
		
	def load_file(self):
		print 
		return open('./data/weather.dat','r')
		
	def eval_line(self, line):
		row = line.split()
		if len(row) < 14:
			return
			
		try:
			min = int(row[2])
			max = int(row[1])
			x_spread = max - min
			if not self.min_spread or self.min_spread > x_spread:
				self.min_spread = x_spread
				self.min_spread_day = int(row[0])
		except ValueError:
			pass
	
	def eval_spread(self):
		file = self.load_file()
		for line in file:
			self.eval_line(line)
		return self.min_spread