Class CSVSaver

java.lang.Object
org.tribuo.data.csv.CSVSaver
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable

public class CSVSaver extends Object implements com.oracle.labs.mlrg.olcut.config.Configurable
Saves a Dataset in CSV format suitable for loading by CSVLoader.

CSVSaver is thread safe and immutable.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default response column name.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Builds a CSV saver using the default separator and quote from CSVIterator.
    CSVSaver(char separator, char quote)
    Builds a CSV saver using the supplied separator and quote.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Output<T>>
    void
    save(Path csvPath, Dataset<T> dataset, String responseName)
    Saves the dataset to the specified path.
    <T extends Output<T>>
    void
    save(Path csvPath, Dataset<T> dataset, Set<String> responseNames)
    Saves the dataset to the specified path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable

    postConfig
  • Field Details

  • Constructor Details

    • CSVSaver

      public CSVSaver(char separator, char quote)
      Builds a CSV saver using the supplied separator and quote.
      Parameters:
      separator - The column separator.
      quote - The quote character.
    • CSVSaver

      public CSVSaver()
      Builds a CSV saver using the default separator and quote from CSVIterator.
  • Method Details

    • save

      public <T extends Output<T>> void save(Path csvPath, Dataset<T> dataset, String responseName) throws IOException
      Saves the dataset to the specified path.
      Type Parameters:
      T - The output type.
      Parameters:
      csvPath - The path to save to.
      dataset - The dataset to save.
      responseName - The name of the response variable.
      Throws:
      IOException - If the disk write failed.
    • save

      public <T extends Output<T>> void save(Path csvPath, Dataset<T> dataset, Set<String> responseNames) throws IOException
      Saves the dataset to the specified path.
      Type Parameters:
      T - The output type.
      Parameters:
      csvPath - The path to save to.
      dataset - The dataset to save.
      responseNames - The response names set.
      Throws:
      IOException - If the disk write failed.