public static void fileWithColdestTemperature() {
   String fileName = null;
   CSVRecord lowestSoFar = null;
   double lowestTemp = 99999;
   DirectoryResource dr = new DirectoryResource();
   for (File f : dr.selectedFiles()) {
     FileResource fr = new FileResource(f);
     CSVRecord currentRow = coldestHourInFile(fr.getCSVParser());
     double currentTemp = Double.parseDouble(currentRow.get("TemperatureF"));
     if (currentTemp < lowestTemp) {
       lowestTemp = currentTemp;
       lowestSoFar = currentRow;
       fileName = f.getName();
     }
     /*
     if (lowestSoFar == null) {
     	lowestSoFar = currentRow;
     	fileName = f.getName();
     	selectedFr = fr;
     } else {
     	lowestSoFar = getLowestOfTwo(currentRow, lowestSoFar);
     	fileName = f.getName();
     	selectedFr = fr;
     }
     */
   }
   System.out.println("Coldest day was in file " + fileName);
   System.out.println("Coldest temperature on that day was " + lowestSoFar.get("TemperatureF"));
   System.out.println("All the Temperatures on the coldest day were:");
 }
  @Test
  public void testFileLowestHumidity() {

    CSVRecord coldestRecord = null;
    DirectoryResource dr = new DirectoryResource();
    String filename = "";

    for (File f : dr.selectedFiles()) {

      FileResource fr = new FileResource(f);

      CSVRecord record = WeatherCSVProblem.lowestHumidityInFile(fr.getCSVParser());

      if (coldestRecord == null) {
        coldestRecord = record;
      } else {
        double recordTemp = Double.parseDouble(record.get("Humidity"));
        double coldestTemp = Double.parseDouble(coldestRecord.get("Humidity"));

        if (recordTemp < coldestTemp) {
          coldestRecord = record;
          filename = f.getName();
        }
      }
    }
    System.out.println(filename);
    System.out.println(
        "Lowest Humidity " + coldestRecord.get("Humidity") + " at " + coldestRecord.get("DateUTC"));
  }
 public static CSVRecord lowestHumidityInManyFiles() {
   CSVRecord lowestSoFar = null;
   DirectoryResource dir = new DirectoryResource();
   for (File file : dir.selectedFiles()) {
     FileResource fr = new FileResource(file);
     CSVParser csv = fr.getCSVParser();
     CSVRecord lowestInFile = lowestHumidityInFile(csv);
     lowestSoFar = getLowestOfTwo(lowestInFile, lowestSoFar);
   }
   return lowestSoFar;
 }
 public static CSVRecord hottestInManyDays() {
   CSVRecord largestSoFar = null;
   DirectoryResource dr = new DirectoryResource();
   for (File f : dr.selectedFiles()) {
     FileResource fr = new FileResource(f);
     CSVRecord currentRow = hottestHourInFile(fr.getCSVParser());
     if (largestSoFar == null) {
       largestSoFar = currentRow;
     } else {
       largestSoFar = getLargestOfTwo(currentRow, largestSoFar);
     }
   }
   return largestSoFar;
 }
 /**
  * Takes selected files and returns name of file with lowest temp
  *
  * @return name of file with lowest temperature
  */
 public static String fileWithColdestTemperature() {
   DirectoryResource dir = new DirectoryResource();
   CSVRecord lowestSoFar = null;
   File lowestFile = null;
   for (File fr : dir.selectedFiles()) {
     FileResource frR = new FileResource(fr);
     CSVParser csv = frR.getCSVParser();
     CSVRecord record = coldestHourInFile(csv);
     if (coldestOfTwo(record, lowestSoFar)) {
       lowestFile = fr;
     }
   }
   return lowestFile.getAbsolutePath();
 }
 public static CSVRecord lowestHumidityInManyFiles() {
   CSVRecord lowestRecordSoFar = null;
   double lowestHumiditySoFar = 101;
   DirectoryResource dr = new DirectoryResource();
   for (File f : dr.selectedFiles()) {
     FileResource fr = new FileResource(f);
     CSVParser parser = fr.getCSVParser();
     CSVRecord record = lowestHumidityInFile(parser);
     double currentHumidity = Double.parseDouble(record.get("Humidity"));
     if (currentHumidity < lowestHumiditySoFar) {
       lowestHumiditySoFar = currentHumidity;
       lowestRecordSoFar = record;
     }
   }
   return lowestRecordSoFar;
 }
  /*
   *  method to load the dictionaries in the given directory and return the HashMap
   */
  private HashMap<String, HashSet<String>> loadDictionaries(DirectoryResource dr) {

    HashMap<String, HashSet<String>> dictMap = new HashMap<String, HashSet<String>>();

    for (File f : dr.selectedFiles()) {
      System.out.println("loading dictionary: " + f.getName());
      FileResource fr = new FileResource(f);
      HashSet<String> dict = readDictionary(fr);
      dictMap.put(f.getName(), dict);
    }

    return dictMap;
  }