title: How to read CSV data by matching the input in java?
body: <p>Trying to create a program where the user is asked to enter a location, if the user enters i.e south it can read from the &quot;Location&quot; column in the csv, and whatever row contains &quot;south&quot; (upper or lowercase accepted), the name(s) from the Name column are printed. So if the user enters south, Holos and Deafer are returned.</p>
  <p>I can't seem to find how to actually print specific rows that contains matching input, and have only been able to print the whole column.</p>
  <p>Any help is much appreciated!</p>
  <p>Csv</p>
  <pre><code>Name, Location
  Holos, South
  Tredies, North
  Warren, West
  Deafer, South
  </code></pre>
  <p>Current code that only reads specific column</p>
  <pre><code>    public void filter() {
          // using buffered reader to read the csv file, still a WIP
          String path = &quot;E:\\IT\\2022\\Further Programming\\s3902169_furtherProgrammingA1\\src\\files\\Melbnb.csv&quot;;
          String line = &quot;&quot;;
  
          System.out.println(&quot;Enter location&quot;);
          String stringInput = readUserInput();
  
          BufferedReader br;
          try {
              br = new BufferedReader(new FileReader(path));
              while ((line = br.readLine()) != null) {
                  String[] values = line.split(&quot;,&quot;);
  
                  if (stringInput.contains(values[1])) {
                      System.out.print(values[0]);
                  }
  
              }
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  
  </code></pre>