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>

public class CSVIterator extends ColumnarIterator implements AutoCloseable
An iterator over a CSV file.
  • Field Details

  • Constructor Details

    • CSVIterator

      public CSVIterator(Reader rdr)
      Builds a CSVIterator for the supplied Reader. Defaults to SEPARATOR for the separator and QUOTE for the quote.
      Parameters:
      rdr - The source to read.
    • CSVIterator

      public CSVIterator(Reader rdr, char separator, char quote)
      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

      public CSVIterator(URI dataFile) throws IOException
      Builds a CSVIterator for the supplied URI. Defaults to SEPARATOR for the separator and QUOTE for the quote.
      Parameters:
      dataFile - The source to read.
      Throws:
      IOException - thrown if the file is not readable in some way.
    • CSVIterator

      public CSVIterator(URI dataFile, char separator, char quote) 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.
      Throws:
      IOException - thrown if the file is not readable in some way.
    • CSVIterator

      public CSVIterator(URI dataFile, char separator, char quote, String[] fields) throws IOException
      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

      public CSVIterator(Reader rdr, char separator, char quote, String[] fields)
      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

      public CSVIterator(Reader rdr, char separator, char quote, List<String> fields)
      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