title: skip header while reading a CSV file in Apache Beam
body: <p>I want to skip header line from a CSV file. As of now I'm removing the header manually before loading it to google storage. </p>
  
  <p>Below is my code : </p>
  
  <pre><code>PCollection&lt;String&gt; financeobj =p.apply(TextIO.read().from("gs://storage_path/Financials.csv"));        
      PCollection&lt;ClassFinance&gt; pojos5 = financeobj.apply(ParDo.of(new DoFn&lt;String, ClassFinance&gt;() { // converting String into classtype
  
          private static final long serialVersionUID = 1L;
          @ProcessElement
          public void processElement(ProcessContext c) {
              String[] strArr = c.element().split(",");
              ClassFinance fin = new ClassFinance();
              fin.setBeneficiaryFinance(strArr[0]);
              fin.setCatlibCode(strArr[1]);
              fin.set_rNR_(Double.valueOf(strArr[2]));
              fin.set_rNCS_(Double.valueOf(strArr[3]));
              fin.set_rCtb_(Double.valueOf(strArr[4]));
              fin.set_rAC_(Double.valueOf(strArr[5]));
              c.output(fin);
          }
      }));
  </code></pre>
  
  <p>I have checked the existing question in stackoverflow but I dont find it promising : <a href="https://stackoverflow.com/questions/28450554/skipping-header-rows-is-it-possible-with-cloud-dataflow">Skipping header rows - is it possible with Cloud DataFlow?
  </a></p>
  
  <p>Any help ?</p>
  
  <p><strong>Edit :</strong> I have tried something like below and it worked :</p>
  
  <pre><code>PCollection&lt;String&gt; financeobj = p.apply(TextIO.read().from("gs://google-bucket/final_input/Financials123.csv"));       
  
      PCollection&lt;ClassFinance&gt; pojos5 = financeobj.apply(ParDo.of(new DoFn&lt;String, ClassFinance&gt;() { // converting String into classtype
  
          private static final long serialVersionUID = 1L;
          @ProcessElement
          public void processElement(ProcessContext c) {  
              String[] strArr2 = c.element().split(",");
              String header = Arrays.toString(strArr2);
              ClassFinance fin = new ClassFinance();
  
                  if(header.contains("Beneficiary"))
                  System.out.println("Header");
                  else {
              fin.setBeneficiaryFinance(strArr2[0].trim());
              fin.setCatlibCode(strArr2[1].trim());
              fin.setrNR(Double.valueOf(strArr2[2].trim().replace("", "0")));
              fin.setrNCS(Double.valueOf(strArr2[3].trim().replace("", "0")));
              fin.setrCtb(Double.valueOf(strArr2[4].trim().replace("", "0")));
              fin.setrAC(Double.valueOf(strArr2[5].trim().replace("", "0")));
              c.output(fin);
              }
          }
      }));
  </code></pre>