Created
May 6, 2022 18:24
-
-
Save sajith-rahim/e34ed87989502efc38852a5c1e77c27f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.csv.CSVFormat; | |
import org.apache.commons.csv.CSVParser; | |
import org.apache.commons.csv.CSVRecord; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.io.Reader; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class CSVReader { | |
private static final String SAMPLE_CSV_FILE_PATH = "./csv-with-header.csv"; | |
public static void main(String[] args) throws IOException { | |
try ( | |
Reader reader = Files.newBufferedReader(Paths.get(SAMPLE_CSV_FILE_PATH)); | |
CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT | |
.withFirstRecordAsHeader() | |
.withIgnoreHeaderCase() | |
.withTrim()); | |
) { | |
/* for (CSVRecord csvRecord : csvParser) { | |
//csvRecord.getRecordNumber() | |
//csvRecord.get("ColumnName") | |
}*/ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment