Package org.gbif.utils.file.csv
Class CSVReader
java.lang.Object
org.gbif.utils.file.csv.CSVReader
- All Implemented Interfaces:
AutoCloseable,Iterator<String[]>,ClosableIterator<String[]>,ClosableReportingIterator<String[]>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intReturn an informative message about the error encountered while iterating over row.Return the Exception encountered while iterating over row.String[]Get the header, or null if noneintbooleanhasNext()booleanReturn true if an error was encountered while iterating over row.String[]next()voidremove()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
headerRows
-
encoding
-
delimiter
-
quoteChar
-
header
-
-
Constructor Details
-
CSVReader
public CSVReader(File source, String encoding, String delimiter, Character quotes, Integer headerRows) throws IOException - Throws:
IOException
-
CSVReader
public CSVReader(InputStream stream, String encoding, String delimiter, Character quotes, Integer headerRows) throws IOException - Throws:
IOException
-
CSVReader
public CSVReader(InputStream stream, String encoding, String delimiter, Character quotes, Integer headerRows, int emptyLineCache) throws IOException - Throws:
IOException
-
-
Method Details
-
getHeader
Get the header, or null if none -
close
- Specified by:
closein interfaceAutoCloseable
-
currLineNumber
- Returns:
- the current line number of the String[] iterator
-
getEmptyLines
- Returns:
- a set of the line numbers of the firsts empty rows found in the file
-
getReadRows
- Returns:
- the number of rows of data that were correctly read from the file
-
hasNext
-
next
-
remove
-
hasRowError
Description copied from interface:ClosableReportingIteratorReturn true if an error was encountered while iterating over row.- Specified by:
hasRowErrorin interfaceClosableReportingIterator<String[]>
-
getErrorMessage
Description copied from interface:ClosableReportingIteratorReturn an informative message about the error encountered while iterating over row. Different from the Exception's message, used to store the row number, row string, etc.- Specified by:
getErrorMessagein interfaceClosableReportingIterator<String[]>
-
getException
Description copied from interface:ClosableReportingIteratorReturn the Exception encountered while iterating over row.- Specified by:
getExceptionin interfaceClosableReportingIterator<String[]>
-