Sangram Anand Sangram Anand - 15 days ago 9
Java Question

Skip first line using Open CSV reader

Here is the line i am using currently

File booleanTopicFile;
// booleanTopicFile is csv file uploaded from form
CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(booleanTopicFile), "UTF-8"));


Want to skip the first line of the csv which contains headings.
I dont want to use any separator as except the default one comma(,) which is already available in default constructor.
In parameterized constructor there is a option to skip no. of lines but how to deal with the 2nd and 3rd param of the constructor.

CSVReader csvReader = new CSVReader(new InputStreamReader(Reader reader, char c, char c1, int index);


--
Thanks

Answer

This constructor of CSVReader class will skip 1st line of the csv while reading the file.

CSVReader reader = new CSVReader(new FileReader(file), ',', '\'', 1);