Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read CSV headers and get them in to a list in java

Tags:

java

csv

I have a CSV with headers for eg:-

Title,Project ID,summary,priority

1,1,Test summary,High

Now i want to get the headers list that are passed in the CSV file.

NOTE: The headers passed will be different every time.

Thanks in advance

like image 952
Tarun Arora Avatar asked Mar 13 '23 04:03

Tarun Arora


1 Answers

You can use CSVReader

String fileName = "data.csv";
CSVReader reader = new CSVReader(new FileReader(fileName ));
// if the first line is the header
String[] header = reader.readNext();
like image 190
Parmod Avatar answered Apr 25 '23 12:04

Parmod