Scott Conway Glen Smith

A Simple CSV Parser for Java under a commercial-friendly Apache 2.0 license and performance tested with JProfiler

Project Members:

Main pages

[What's new] - change log and release news combined.

[FAQ] - Frequently Asked Questions

[Submissions] - Want to report a bug/feature request or better yet submit an patch with a new feature or defect fix! Please read me first for some advice to make things easier for both of us.

openCSV api - Javadocs for the project.

Project Reports - Generated my maven site. Contains the JaCoCo, findbugs, checkstyles, as well as the javadocs for the project.

Project Information - project information generated by maven site plugin.


Wiki: FAQ
Wiki: What's new


  • Ankit G
    Ankit G

    I have few doubts regarding OpenCSV:

    • Does openCSV read file line-by-line or the whole at once into the memory ?
    • Does OpenCSV provide any in-built formatting validations. If yes, are they customizable ?
    • Is multi-threading in any form supported by OpenCSV ? For my code I'm actually aiming for thread-pooling. Example: Say my CSV consists of 100 records or lines (assuming each record per line). Now I want to create thread T1 and make it read records 1-10, create T2 and make it read records from 11-20, T3 21-30 and so on....
      So, does SuperCSV has in-built support for this ?? or if I have to do it manually, then how ?
  • Scott Conway
    Scott Conway

    Sorry its been over a year but life has been busy. As for your questions.

    1. line-by-line or all at once: your choice - if you have a memory constraint you can create a CSVParser and have it convert a file line by line into an array of string or the CSVBuilder readNext. Or if you have memory you can use the CSVToBean to get a list of objects with the items in your file mapped into it.

    2. built in formatters - yes but I have not used anything but the default. If you use the HeaderColumnNameMappingStrategy it uses java.bean.PropertyDescriptor to translate data. You should be able to define your own mapping strategy and inject in your own property descriptors to allow formatting of data. But honestly what I would consider is to use the HeaderColumnNameMappingStrategy and CSVToBean to create a temporary DTO (Data Transfer Object) whose getters return the data in the format you desire.

    3. Thread safe - no. The fact we use ArrayList tells me we are thread unsafe. Unless you have MASSIVE files though I would not worry. At work we were able to parse a 20k line file with 80 columns in less than a minute. Though that was a rather beefy box and I never tried that large of a file on my 2007 MBP. You will have to do the threading yourself. Sorry but I do not know if SuperCSV handles multi threading.