Comma-Separated-Values-Loader (csv)

This loader parses csv (comma-separated values) files and returns the resulting tabular data.

Loader name: csv
Input type: csv files or any text file
Default file extension: .csv
Output type: tabular data

Options

  • delimiter: Optional single character to use as a column delimiter. Defaults to a comma ,.

    Type: string

  • primaryKey: Optionally define which column to use as the primary key (i.e. independent variable). Defaults to using the columns defined in the file.

    Type: string

  • columns: Optionally manipulate columns. Defaults to using the columns defined in the file.

    Type: string[] or {[old: string]: string}

    If an array is given, then only the entries given in the array are included. If an object is given, then the columns are renamed. The keys correspond to the old column names, and the values are the new names.
    Example: {a: 'x'} renames the column 'a' to 'x' and leaves all other columns as-is.

  • headerLine: Optionally define a line to be the header line. Defaults to line 1.

    Type: number

  • dataLine: Optionally define on which line to begin reading the data. Defaults to headerLine +1.

    Type: number

  • filter: Optionally omit rows based on criteria.

    Type: object

  • allowInconsistentColumns: Allow data where the number of columns in the data does not match the number of columns in the header. The default is false, i.e. strict behavior.

    Type: boolean

Example of resource definition in YAML-format:

name: resource_name                 # if omitted, name defaults to path. Not required for defining case data
input: ./path/to/file               # obligatory
loader: csv                         # required, if file extension other than `.csv`
options:
  delimiter: ;                      # set semicolons as delimiters
  primaryKey: T                     # set column T as independent variable
  headerLine: 2                     # e.g.: if column names start on line 2
  dataLine: 4                       # e.g.: if data starts on line 4
  filter:
    z:                              # from column z:
      $gte: 0                       # include rows with values greater than or equal to 0
      $lte: 0.3                     # include rows with values lower than or equal to 0.3
  allowInconsistentColumns: true    # Example use case: The data lines contain a trailing delimiter

  # The columns option can be either an object *or* an array
  # If an object is specified, then renames columns
  columns:                   
    T: Temperature                  # rename column T to Temperature

  # If an array is specified, then includes only the listed columns
  columns:
    - H2O                           # include column H2O as-is

results matching ""

    No results matching ""