Class CsvTools

java.lang.Object
com.illumon.iris.db.tables.utils.csv.CsvTools

public class CsvTools
extends Object
Util class that supports and handles the changes needed to migrate to new dhc-fast-csv parser.
  • Constructor Details

  • Method Details

    • getColumnHeaders

      @NotNull public static List<String> getColumnHeaders​(@NotNull InputStream stream, @NotNull io.deephaven.csv.CsvSpecs specs) throws IOException
      Return the column headers as list using the values from the first row. To avoid reading the entire file the CsvSpecs should restrict the num of rows to be read to 1, this check is enforced.
      Parameters:
      stream - An InputStream providing access to the CSV data.
      specs - The CsvSpecs
      Returns:
      Return the column headers using the values from the first row.
      Throws:
      IOException
    • readCsv

      public static Table readCsv​(InputStream stream, String format, boolean v2, StatusCallback progress, boolean noHeader, @Nullable Collection<String> header) throws IOException
      Creates an in-memory table from stream by importing CSV data according to the specs. The stream will be closed upon return.
      Parameters:
      stream - an InputStream providing access to the CSV data.
      format - can be null a delimiter or one of DEFAULT, TDF, EXCEL, MYSQL, RFC4180 and TRIM
      v2 - whether the process imports using the older QueryTable processing (v2 = true) or the newer InMemoryTable processing (v2 = false).
      progress - a StatusCallback object that can be used to log progress details or update a progress bar. If passed explicitly as null, a StatusCallback instance will be created to log progress to the current logger.
      noHeader - boolean indicates if data contains header
      header - Column names to use as, or instead of, the header row for the CSV.
      Returns:
      a Deephaven Table object
      Throws:
      IOException
    • getCsvSpecsBuilder

      @Nullable public static io.deephaven.csv.CsvSpecs.Builder getCsvSpecsBuilder​(@Nullable String format, boolean hasHeader, @Nullable Collection<String> headers)
      Returns the CsvSpecs.Builder created with appropriate properties.
      Parameters:
      format - can be null a delimiter or one of DEFAULT, TDF, EXCEL, MYSQL, RFC4180 and TRIM
      hasHeader - true or false to indicate if data includes header row
      headers - Column names to use as, or instead of, the header row for the CSV.
      Returns:
      CsvSpecs.Builder