title: read csv file most booked rooms
body: <p>I've got a project resit from university to get done, its basically to return a bunch of things from a CSV file in java.</p>
  <p>I've managed to do most of it from my previous attempt but one part I'm stuck on is how to read a CSV file but only a particular part of the file: the room with the most booked time and for it to be displayed in the terminal when jmh is run and made a new jar file. my first attempt was hard-coding and although it works it's not what the lecturer wanted. any help or directional pointers would be great code bellow is the way the lecturer didn't want it.</p>
  <p>Also, the format of the CSV file is A) id B) room name C) date D) time E) length of booking F) person booking</p>
  <p>public String[] getTopRoomsBooked(int n) {</p>
  <pre><code>    HashMap&lt;String, Integer&gt; rooms = new HashMap&lt;String, Integer&gt;();
  
      rooms.put(&quot;Gower&quot;, 281);
      rooms.put(&quot;Usk&quot;, 291);
      rooms.put(&quot;Wye&quot;, 283);
      rooms.put(&quot;Bala&quot;, 282);
      rooms.put(&quot;Pen y Fan&quot;, 292);
      rooms.put(&quot;Llangorse&quot;, 290);
      rooms.put(&quot;Snowdon&quot;, 288);
      rooms.put(&quot;Taff&quot;, 296);
      rooms.put(&quot;Cadair Idris&quot;, 292);
  
      for (String i : rooms.keySet()) {
          System.out.println(&quot;Room name: &quot; + i + &quot; Amount of time: &quot; + rooms.get(i));
      }
  
      System.out.println();
  
      List&lt;Integer&gt; timeBooked = new ArrayList&lt;&gt;(rooms.values());
  
      Collections.sort(timeBooked, Collections.reverseOrder());
  
      if (n == 1) {
          System.out.println(&quot;RoomName : Taff &quot; + timeBooked.get(n - 1));
      } else if (n == 3) {
          System.out.println(&quot;1: Taff &quot; + timeBooked.get(n - 3));
          System.out.println(&quot;2: Cadiar Idris &quot; + timeBooked.get(n - 2));
          System.out.println(&quot;3: Pen y Fan &quot; + timeBooked.get(n - 1));
  
      } else if (n == 5) {
          System.out.println(&quot;1: Taff &quot; + timeBooked.get(n - 5));
          System.out.println(&quot;2: Cadair Idris &quot; + timeBooked.get(n - 4));
          System.out.println(&quot;3: Pen y Fan &quot; + timeBooked.get(n - 3));
          System.out.println(&quot;4: Usk &quot; + timeBooked.get(n - 2));
          System.out.println(&quot;5: Llangorse &quot; + timeBooked.get(n - 1));
      } else if (n == 9) {
          System.out.println(&quot;1: Taff &quot; + timeBooked.get(n - 9));
          System.out.println(&quot;2: Cadair Idris &quot; + timeBooked.get(n - 8));
          System.out.println(&quot;3: Pen y Fan &quot; + timeBooked.get(n - 7));
          System.out.println(&quot;4: Usk &quot; + timeBooked.get(n - 6));
          System.out.println(&quot;5: Llangorse &quot; + timeBooked.get(n - 5));
          System.out.println(&quot;6: Snowden &quot; + timeBooked.get(n - 4));
          System.out.println(&quot;7: Wye &quot; + timeBooked.get(n - 3));
          System.out.println(&quot;8: Bala &quot; + timeBooked.get(n - 2));
          System.out.println(&quot;9: Gower &quot; + timeBooked.get(n - 1));
      }
  
      return null;
  
  }
  </code></pre>