deephaven.csv#

The deephaven.csv module supports reading an external CSV file into a Deephaven table and writing a Deephaven table out as a CSV file.

read(path, header=None, headless=False, header_row=0, skip_rows=0, num_rows=9223372036854775807, ignore_empty_lines=False, allow_missing_columns=False, ignore_excess_columns=False, delimiter=',', quote='"', ignore_surrounding_spaces=True, trim=False)[source]#

Read the CSV data specified by the path parameter as a table.

Parameters:
  • path (str) – a file path or a URL string

  • header (Dict[str, DType]) – a dict to define the table columns with key being the name, value being the data type

  • headless (bool) – whether the csv file doesn’t have a header row, default is False

  • header_row (int) – the header row number, all the rows before it will be skipped, default is 0. Must be 0 if headless is True, otherwise an exception will be raised

  • skip_rows (long) – number of data rows to skip before processing data. This is useful when you want to parse data in chunks. Defaults to 0

  • num_rows (long) – max number of rows to process. This is useful when you want to parse data in chunks. Defaults to the maximum 64bit integer value

  • ignore_empty_lines (bool) – whether to ignore empty lines, default is False

  • allow_missing_columns (bool) – whether the library should allow missing columns in the input. If this flag is set, then rows that are too short (that have fewer columns than the header row) will be interpreted as if the missing columns contained the empty string. Defaults to false.

  • ignore_excess_columns (bool) – whether the library should allow excess columns in the input. If this flag is set, then rows that are too long (that have more columns than the header row) will have those excess columns dropped. Defaults to false.

  • delimiter (str) – the delimiter used by the CSV, default is the comma

  • quote (str) – the quote character for the CSV, default is double quote

  • ignore_surrounding_spaces (bool) – Indicates whether surrounding white space should be ignored for unquoted text fields, default is True

  • trim (bool) – indicates whether to trim white space inside a quoted string, default is False

Return type:

Table

Returns:

a table

Raises:

DHError

write(table, path, cols=[])[source]#

Write a table to a standard CSV file.

Parameters:
  • table (Table) – the source table

  • path (str) – the path of the CSV file

  • cols (List[str]) – the names of the columns to be written out

Raises:

DHError

Return type:

None