in_csv

Read csv file and output the data to flowdata or blackboard.

Description

  • Read csv file and output the data to flowdata or blackboard.

  • Output format can be chosen array, dict or key_value.

Parameters

Parameter

Type

Required

Default

Comment

format

str

No

key_value

Output format.

Choose array, dict or key_value.

out_bb

bool

No

False

out_field

str

No

None

path

path

Yes

-

The path to the csv file to read.

Examples

# Assume following csv file is located at "./file.csv"
# id, name
# foo, John
# bar, Tom

# Read the csv file as key_value and output it to blackboard
# Output: {"csv": {'foo': 'John', 'bar': 'Tom'}}
- in_csv:
    name: "csv"
    path: "./file.csv"
    format: "key_value"
    out_bb: yes

# Read the csv file as dict
# Output: {"csv": [{'id': 'foo', 'name': 'John'}, {'id': 'bar', 'name': 'Tom'}]}
- in_csv:
    name: "csv"
    path: "./file.csv"
    format: "dict"

# Read the csv file as dict
# Output: {"csv": [["id", "name"], ["foo", "John"], ["bar", "Tom"]]}
- in_csv:
    name: "csv"
    path: "./file.csv"
    format: "array"