Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencsv CSV Reader - Read from specific row onwards.

Tags:

java

csv

I've been searching this everywhere, I'm probably just being thick but is there a way to read a csv file from a particular row onwards? I have a csv file but want to read the data from the 14th row onwards. Below is my csv reader.

  CSVReader reader=new CSVReader(new FileReader(filename1));
  String [] value ;

  while((value=reader.readNext())!=null){

The data inside the csv is something like this

    1   djennings93
    2   27/02/2014
    3   13:31
    ...
    14  26/02/14 14:25:00, www.google.co.uk, 50, Google

I'd like to ignore the data from lines 1-13

like image 406
djennings93 Avatar asked Feb 18 '26 06:02

djennings93


1 Answers

You can skip the first 13 lines by doing:

CSVReader reader = new CSVReader(new FileReader("yourfile.csv"), '\t', '\'', 13);

Have a look here. (question Can I use my own separators and quote characters?)

This will result in reading the data from the 14th line onward.

like image 76
Boris Avatar answered Feb 20 '26 19:02

Boris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!