def getWeather():

  # Name of the Web page as file
  BOMfile = "bomInternationalObs.htm"

  # Open the file and read it
  file = open(getMediaPath(BOMfile), "rt")
  fileList = file.readlines()
  file.close()

  print "Number of lines in file:", len(fileList)

  weatherList = []

  # Process the file list until we find the start string

  i = 0  # Counter in list

  while (fileList[i].find("----- start -----") < 0):
    i = i + 1

  # Process the file list until we find the end string

  while (fileList[i].find("----- end -----") < 0):
    weatherList.append(fileList[i])
    i = i + 1

  print "Number of weather observations:", len(weatherList)

  #set up variables for searching through weather data
  snowcities = 0
  totaltemps = 0
  count = 0
  maxtemp = -99
  maxtempStation = ''
  mintemp = 999
  mintempStation = ''

  for obs in weatherList: #loop for all weather observations
    #print weather data for each city
    print "City:", obs[:11], obs[44:47], "degC ", obs[66:71]
    
    #add up the global temperature to calculate an average
    if (obs[44:47] != ' --'):
      totaltemps = totaltemps + (int(obs[44:47]))
      count = count + 1
    
    #count the number of snow observations
    if (obs[66:70] == 'Snow'):
      snowcities = snowcities + 1
    
    #find the maximum temperature and what station it was at
    if (obs[44:47] != ' --'):
      if (int(obs[44:47])) > maxtemp:
        maxtemp = (int(obs[44:47]))
        maxtempStation = obs[:11]
    
    #find the minimum temperature and what station it was observed at
    if (obs[44:47] != ' --'):
      if (int(obs[44:47])) < mintemp:
        mintemp = (int(obs[44:47]))
        mintempStation = obs[:11]
    

  #print global weather observations
  print "Number of cities with snowy conditions: ", snowcities
  print "Average Global Temperature:", (totaltemps/count), "degC"
  print "Maximum Global Temperature:", maxtemp, "Observed at:", maxtempStation
  print "Minimum Global Temperature:", mintemp, "Observed at:", mintempStation

