Support random access reader (read a specific row range)
A fast, programmer-friendly, free CSV library for Java
Brought to you by:
jamesbassett,
kbg
I'm evaluating it to use with java batch applications (JSR-352) to implement csv javax.batch.api.chunk.ItemReader and javax.batch.api.chunk.ItemWriter. One of the difficulties is supercsv doesn't support random access read. For example, for a csv file with 1000 rows, I need to read row 500 to row 600 only.
Currently I extend AbstractCsvReader and calling getRow() repeatedly till the desired starting row. It avoids populating beans and running processors, but still doesn't seem very efficient.
I noticed CommentMatcher can be used to skip reading unwanted rows, but it doesn't keep row counting for skipped rows.
You have to parse the file in order to know when a line ends and a new begins due to a row may span multiple lines.