title: Filter specific rows when loading csv file
body: <p>So I have this POJO class:</p>
  
  <pre><code>public class Player {
  
   @CsvBindByName
   private String simTime;
  
   @CsvBindByName
   private String playerId;
  
   @CsvBindByName
   private String dimX;
  
   @CsvBindByName
   private String offX;
  
   @CsvBindByName
   private String dimY;
  
   @CsvBindByName
   private String roadS;
  
   @CsvBindByName
   private String roadT;
  
   public String getSimTime() {     
      return simTime;
   }
  
   public void setSimTime(String simTime) {
      this.simTime = simTime;
   }
  
   public String getPlayerId() {
      return playerId;
   }
  
   public void setPlayerId(String playerId) {
      this.playerId = playerId;
   }
  
   public String getDimX() {
      return dimX;
   }
  
   public void setDimX(String dimX) {
      this.dimX = dimX;
   }
  
   public String getOffX() {
      return offX;
   }
  
   public void setOffX(String offX) {
      this.offX = offX;
   }
  
   public String getDimY() {
      return dimY;
   }
  
   public void setDimY(String dimY) {
      this.dimY = dimY;
   }
  
   public String getRoadS() {
      return roadS;
   }
  
   public void setRoadS(String roadS) {
      this.roadS = roadS;
   }
  
   public String getRoadT() {
      return roadT;
   }
  
   public void setRoadT(String roadT) {
      this.roadT = roadT;
   }
  
   @Override
   public String toString() {
      return "Player{" + "simTime=" + simTime + ", playerId=" + playerId + ", dimX=" + dimX + ", offX=" + offX + ", dimY=" + dimY + ", roadS=" + roadS + ", roadT=" + roadT + '}';
   }
  
  }
  </code></pre>
  
  <p>And I have a large excel file with a LOT MORE columns. One of the columns in my excel file is called <code>objectId</code>.  </p>
  
  <p>Using this code:</p>
  
  <pre><code>private void loadCSVFiles() throws Exception {
      List&lt;Player&gt; beans = new CsvToBeanBuilder(new FileReader("C:\\Users\\noname\\Desktop\\ABP_S31\\ABP20180809_S31_FG_Notbremsung_100.csv"))
              .withType(Player.class)
              .withIgnoreLeadingWhiteSpace(true)
              .build()
              .parse();
      beans.forEach(System.out::println);
  
  }
  </code></pre>
  
  <p>I managed to get specific columns which I need. 
   The problem I am having is that right now I only need rows where the <code>playerId</code> equals <code>objectId</code>. Obviously I could add <code>objectId</code> as a class property and after I load the file I could go through the entire list and filter the rows AGAIN. But I don't want to this as</p>
  
  <ol>
  <li>performance issues</li>
  <li>objectId has actually nothing to do with my Player class</li>
  </ol>
  
  <p>Also I could load the entire excel file and filter the columns, but I also don't want this because for me personally it is more readable if I do this the current way. Is there a way to solve this problem or do I have to use the options above?</p>
  
  <p>I tried using <code>csvToBeanFilter</code> but the <code>getColumnIndex</code> method is deprecated: <a href="http://opencsv.sourceforge.net/apidocs/com/opencsv/bean/MappingStrategy.html#getColumnIndex(java.lang.String)" rel="nofollow noreferrer">docu</a></p>