ronan
ronan

Reputation: 4672

Validating a particular column in CSV

I am validating a particular column in a CSV file , I have basically two approaches i.e

Please suggest a better approach

Upvotes: 0

Views: 4504

Answers (1)

OverZealous
OverZealous

Reputation: 39570

Don't write your own CSV parser. CSV is actually more complicated than you might at first guess. (Examples: multi-line values, encapsulated fields, escaped characters, and more. Commas don't always separate fields!)

Use opencsv, which is a full-featured pure-Java CSV parser.

This parser will easily let you loop over a CSV file, and process individual columns and rows. Examples are given in the link above.

Edit: Also, I forgot to mention, it is Apache2 licensed, so it can safely be embedded in commercial projects!

Upvotes: 1

Related Questions