Skip first line using Open CSV reader

Sangram Anand picture Sangram Anand · Nov 27, 2012 · Viewed 31.1k times · Source

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

Abhijeet Doshi picture Abhijeet Doshi · Feb 1, 2013

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

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