title: How can I skip the first line of a csv in Java?
body: <p>I want to skip the first line and use the second as header.</p>
  
  <p>I am using classes from apache commons csv to process a CSV file.</p>
  
  <p>The header of the CSV file is in the second row, not the first (which contains coordinates). </p>
  
  <p>My code looks like this: </p>
  
  <pre><code>static void processFile(final File file) {
      FileReader filereader = new FileReader(file);
      final CSVFormat format = CSVFormat.DEFAULT.withDelimiter(';');
      CSVParser parser = new CSVParser(filereader, format);
      final List&lt;CSVRecord&gt; records = parser.getRecords();
      //stuff
  }
  </code></pre>
  
  <p>I naively thought,</p>
  
  <pre><code>CSVFormat format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(;)
  </code></pre>
  
  <p>would solve the problem, as it's different from withFirstRowAsHeader and I thought it would detect that the first row doesn't contain any semicolons and is not a record. It doesn't. I tried to skip the first line (that CSVFormat seems to think is the header) with</p>
  
  <pre><code>CSVFormat format = CSVFormat.DEFAULT.withSkipHeaderRecord().withFirstRecordAsHeader().withDelimiter(;);
  </code></pre>
  
  <p>but that also doesn't work. What can I do?  What's the difference between withFirstRowAsHeader and withFirstRecordAsHeader?</p>