Reputation: 65
I have a csv file. columns in csv file - "SNo. StateName CityName AreaName PinCode NonServ.Area MessangerService Remark". The column CityName has repeated values.
Ex: In many records, it has unique value (Delhi). Is there any approach in java to read that csv file and get the distinct values from that column of the csv file.
Upvotes: 1
Views: 5092
Reputation: 11384
The only way I can think of is to do it row by row and store each value into an array-type structure. Using a set structure such as HashSet or TreeSet will ensure unique values.
The other option, which isn't what you were looking for but might work depending on your project is to use a database instead of a csv file. It then becomes very easy to select distinct values in a column.
Upvotes: 1