Breadcrumbs

Workflows Helper - Filter CSV

Overview

How to use the Filter CSV Helper

1. Provide inputs:

–filepath (optional, defaults to current directory) –filename (required, must be .csv) –column (required, column name to filter on) –value (required, exact value to match)

2. Run example:

python filtercsv.py –filepath ./data –file_name customers.csv –column Country –value US

3. Output:

customersmatches.csv (rows where Country == US) customersnonmatches.csv (rows where Country != US)

Variables

Name

Reference

Type

Required

Default

Options

Description

Workflows Folder Name

SOURCE_FILE_PATH

Alphanumeric

-

-

Name of the local folder on Workflows the target file is expected to be. {file_name}_matches.csv and {file_name}_nonmatches.csv will be created in this folder. If left blank, will look in the home directory.

Workflows File Name

FILE

Alphanumeric

-

-

Name of file to preview. Should be `.csv` extension.

Column to Filter

COLUMN

Alphanumeric

-

-

Target column name. Ensure the column name is an exact match.

Value

VALUE

Alphanumeric

-

-

Exact value that should match in the column you chose above.

YAML

Below is the YAML template

YAML

source:
  template: Workflows Helper - Filter CSV
  inputs:
    SOURCE_FILE_PATH:
    FILE:
    COLUMN:
    VALUE:
  type: TEMPLATE
guardrails:
  retry_count: 1
  retry_wait: 0h0m0s
  runtime_cutoff: 1h0m0s
  exclude_exit_code_ranges:
    - 101
    - 102
    - 103
    - 104
    - 105
    - 106
    - 199