I am using CsvReader library and want to read a specific row from a csv file in java. Sample csv :
**Name**, **Address**, **Email-Id**
student, studentaddress, [email protected]
student2, student2address, [email protected]
employee, employeeaddres1, [email protected]
I want to read the row where name is 'student2'. Could you please provide a solution?
Thanks in advance.
As rows have different sizes in bytes, and as the CSV format doesn't contain an index, you can't have a random access directly to one row.
So you must read all precedent rows and simply skip them until you're at the desired one.
I have some experience with this type of operation , just try this API http://opencsv.sourceforge.net/
we have an option to skip the first n records
eg: CSVReader reader = new CSVReader(new FileReader("yourfile.csv"), '\t', '\'', 2);
this shows it will skip the first 2 records. look through it
Other API's
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With