Class CsvUtils
java.lang.Object
org.lfenergy.compas.sct.commons.util.CsvUtils
Utility class to parse CSV files.
This utility class intention is to normalize all CSV inputs in the project:
- Separator is
SEPARATOR
.
- Lines starting with COMMENT_PREFIX
will be ignored. Allow to write copyright and headers at the beginning of the file for example.
- blank lines are ignored-
Method Summary
-
Method Details
-
parseRows
Read CSV from a resource- Parameters:
resourcePath
- path of the resourcecharset
- charset of the resourcetargetClass
- Each row will be mapped to this class.- Returns:
- list of rows, mapped as targetClass
-
parseRows
Read CSV from a Reader. Reader will be automatically closed when the method returns or throw an exception.- Parameters:
csvSource
- CSV inputtargetClass
- Each row will be mapped to this class.- Returns:
- list of rows, mapped as targetClass
-