Miller
Miller

Reputation: 744

Csv file reading in java

My program is to read values from a csv file.I am to totally confused with the following part of code in my program reader.readHeaders() and reader.readRecord()(these methods are undescribed in my eclipse) methods in java....Because it showing me errors. Is there any jar files need to be added to my program?

try {
    System.out.println("file name"+fileName);
    CsvReader products = new CsvReader("categories/"+fileName);        
    products.readHeaders(); //I'm getting an error here

    while (products.readRecord()) { //I'm also getting an  error here
       //code is here...
    }

The jarfiles that I already added is that

  1. opencsv-2.2.jar
  2. javacsv.jar

Upvotes: 1

Views: 478

Answers (1)

You are using a method from the wrong library. readHeaders() is a method in com.csvreader.CsvReader. But you are using OpenCSV (com.opencsv.CSVReader), for which the method is readNextSilently().

Upvotes: 1

Related Questions