I want to search by column value and retrieve that particular row from a csv file using java. Suppose I provide “ABC123” than the result should come in this format “ABC123, SW, Php”.
Here is the csv file format:
Employee_Id, Designation, Domain
ABC123, SW, Php
XYZ456, SW, Java
So how do I search any clue. Thanks .
Read the file line by line with a
BufferedReaderwrapped around aFileReader. Stop when you hit a line thatstartsWiththe thing you’re looking for. Close the reader and return the line.Edit:
There’s no fancy searching or optimising you can do here, unless the CSV file has some sort of order you haven’t mentioned. You just have to read each line until you find the one you want.