title: Skip blank lines while reading .csv file using opencsv (java)
body: <p>Good day everyone! 
  My target is to make csv reader to skip the blank lines while parsing a file, do nothing basically, only get me the rows with at least one value.
  At the moment I have two methods -> 1st is just reading all rows as List of Strings array and returns it, 2nd converts the result into List of Lists of Strings, both are bellow: </p>
  
  <pre><code>private List&lt;String[]&gt; readCSVFile(File filename) throws IOException {
  
      CSVReader reader = new CSVReader(new FileReader(filename));
      List&lt;String[]&gt; allRows = reader.readAll();
  
      return allRows;
  
  }
  
  public List&lt;List&lt;String&gt;&gt; readFile(File filename) throws IOException {
  
          List&lt;String[]&gt; allRows = readCSVFile(filename);     
          List&lt;List&lt;String&gt;&gt; allRowsAsLists = new ArrayList&lt;List&lt;String&gt;&gt;();      
          for (String[] rowItemsArray :  allRows) {
              List&lt;String&gt; rowItems = new ArrayList&lt;String&gt;();
              rowItems.addAll(Arrays.asList(rowItemsArray));
              allRowsAsLists.add(rowItems);
  
          }
      return allRowsAsLists;
  
  }
  </code></pre>
  
  <p>My first thought was to check (in the 2'nd method) the length of an array if its 0 just to ignore it - which would be something like this: </p>
  
  <pre><code>for (String[] rowItemsArray :  allRows) {
              **if(rowItemArray.length == 0) continue;**
              List&lt;String&gt; rowItems = new ArrayList&lt;String&gt;();
              rowItems.addAll(Arrays.asList(rowItemsArray));
              allRowsAsLists.add(rowItems);
  
  }  
  </code></pre>
  
  <p>Unfortunately that didn't work for the reason that even if the row is blank it still returns an array of elements - empty Strings in fact. Checking an individual String is not an option as there are 100+ columns and this is variable. 
  Please suggest what’s the best way to achieve this.
  Thanks.</p>
  
  <p>Sorted it out this way:</p>
  
  <pre><code>    public List&lt;List&lt;String&gt;&gt; readFile(File filename) throws IOException {
  
              List&lt;String[]&gt; allRows = readCSVFile(filename, includeHeaders, trimWhitespacesInFieldValues);       
              List&lt;List&lt;String&gt;&gt; allRowsAsLists = new ArrayList&lt;List&lt;String&gt;&gt;();      
              for (String[] rowItemsArray :  allRows) {
                  **if(allValuesInRowAreEmpty(rowItemsArray)) continue;**
                  List&lt;String&gt; rowItems = new ArrayList&lt;String&gt;();
                  rowItems.addAll(Arrays.asList(rowItemsArray));
                  allRowsAsLists.add(rowItems);
  
              }
              return allRowsAsLists;
  
          }
  
      private boolean allValuesInRowAreEmpty(String[] row) {
          boolean returnValue = true;
          for (String s : row) {
              if (s.length() != 0) {
                  returnValue = false;
              }
          }
          return returnValue;
      }
  </code></pre>