@Test
  public void testSkipFileSplits() throws Exception {
    FileSystem fs = dataDir.getFileSystem(job);
    FileInputFormat.setInputPaths(job, dataDir);

    // First Dir with 1 File
    Path dir1_file1 = new Path(dataDir, "skipfile1.csv");
    writeTextFile(dir1_file1,
        "dir1_header\n" +
            "dir1_file1_line1\n" +
            "dir1_file1_line2\n" +
            "dir1_footer"
    );

    SkippingTextInputFormat inputFormat = new SkippingTextInputFormat();
    // One header and one footer line to be deducted
    inputFormat.configure(job, 1, 1);

    FileInputFormat.setInputPaths(job, dir1_file1);
    InputSplit[] splits = inputFormat.getSplits(job, 2);

    assertTrue(splits.length == 2);

    // Read all values.
    List<String> received = new ArrayList<String>();
    for (int i=0; i < splits.length; i++) {
      RecordReader<LongWritable, Text> reader =
          inputFormat.getRecordReader(splits[i], job, reporter);

      HiveInputFormat.HiveInputSplit hiveInputSplit =
          new HiveInputFormat.HiveInputSplit(splits[i], inputFormat.getClass().getName());
      assertTrue(hiveInputSplit.getInputSplit().getClass() == FileSplit.class);

      LongWritable key = reader.createKey();
      Text value = reader.createValue();
      while (reader.next(key, value)) {
        received.add(value.toString());
      }
      reader.close();
    }
    // make sure we skipped the header and the footer across splits
    assertTrue(received.size() == 2);
    assertTrue(!received.get(0).contains("header"));
    assertTrue(!received.get(received.size()-1).contains("footer"));
  }
Test CSV input file with header/footer skip.
ql/src/test/org/apache/hadoop/hive/ql/io/TestSkippingTextInputFormat.java