Class CSVIterator
java.lang.Object
com.oracle.labs.mlrg.olcut.util.IOSpliterator<ColumnarIterator.Row>
org.tribuo.data.columnar.ColumnarIterator
org.tribuo.data.csv.CSVIterator
- All Implemented Interfaces:
AutoCloseable,Iterator<ColumnarIterator.Row>,Spliterator<ColumnarIterator.Row>
An iterator over a CSV file.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.tribuo.data.columnar.ColumnarIterator
ColumnarIterator.RowNested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T, T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T,T_CONS, T_SPLITR>> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charDefault quote character.static final charDefault separator character.Fields inherited from class org.tribuo.data.columnar.ColumnarIterator
currentRow, fieldsFields inherited from class com.oracle.labs.mlrg.olcut.util.IOSpliterator
DEFAULT_BATCH_SIZE, DEFAULT_CHARACTERISTICSFields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED -
Constructor Summary
ConstructorsConstructorDescriptionCSVIterator(Reader rdr) Builds a CSVIterator for the supplied Reader.CSVIterator(Reader rdr, char separator, char quote) Builds a CSVIterator for the supplied Reader.CSVIterator(Reader rdr, char separator, char quote, String[] fields) Builds a CSVIterator for the supplied Reader.CSVIterator(Reader rdr, char separator, char quote, List<String> fields) Builds a CSVIterator for the supplied Reader.CSVIterator(URI dataFile) Builds a CSVIterator for the supplied URI.CSVIterator(URI dataFile, char separator, char quote) Builds a CSVIterator for the supplied URI.CSVIterator(URI dataFile, char separator, char quote, String[] fields) Builds a CSVIterator for the supplied URI.CSVIterator(URI dataFile, char separator, char quote, List<String> fields) Builds a CSVIterator for the supplied URI. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected Optional<ColumnarIterator.Row> getRow()Returns the next row of data based on internal state stored by the implementor, orOptional.empty()if there is no more data.Methods inherited from class org.tribuo.data.columnar.ColumnarIterator
forEachRemaining, getFields, hasNext, next, tryAdvanceMethods inherited from class com.oracle.labs.mlrg.olcut.util.IOSpliterator
characteristics, estimateSize, trySplitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Field Details
-
SEPARATOR
public static final char SEPARATORDefault separator character.- See Also:
-
QUOTE
public static final char QUOTEDefault quote character.- See Also:
-
-
Constructor Details
-
CSVIterator
-
CSVIterator
Builds a CSVIterator for the supplied Reader.- Parameters:
rdr- The source to read.separator- The separator character to use.quote- The quote character to use.
-
CSVIterator
Builds a CSVIterator for the supplied URI. Defaults toSEPARATORfor the separator andQUOTEfor the quote.- Parameters:
dataFile- The source to read.- Throws:
IOException- thrown if the file is not readable in some way.
-
CSVIterator
Builds a CSVIterator for the supplied URI.- Parameters:
dataFile- The source to read.separator- The separator character to use.quote- The quote character to use.- Throws:
IOException- thrown if the file is not readable in some way.
-
CSVIterator
Builds a CSVIterator for the supplied URI. If headers is null or an empty array, read the headers from the csv file.- Parameters:
dataFile- The source to read.separator- The separator character to use.quote- The quote character to use.fields- The headers to use.- Throws:
IOException- thrown if the file is not readable in some way.
-
CSVIterator
public CSVIterator(URI dataFile, char separator, char quote, List<String> fields) throws IOException Builds a CSVIterator for the supplied URI.- Parameters:
dataFile- The source to read.separator- The separator character to use.quote- The quote character to use.fields- The headers to use.- Throws:
IOException- thrown if the file is not readable in some way.
-
CSVIterator
Builds a CSVIterator for the supplied Reader. If headers is null or an empty array, read the headers from the csv file.- Parameters:
rdr- The source to read.separator- The separator character to use.quote- The quote character to use.fields- The headers to use.
-
CSVIterator
Builds a CSVIterator for the supplied Reader. If headers is null or an empty list, read the headers from the csv file.- Parameters:
rdr- The source to read.separator- The separator character to use.quote- The quote character to use.fields- The headers to use.
-
-
Method Details
-
getRow
Description copied from class:ColumnarIteratorReturns the next row of data based on internal state stored by the implementor, orOptional.empty()if there is no more data.- Specified by:
getRowin classColumnarIterator- Returns:
- The next row of data or None.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-