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 |
If this parameter is set to True, the data is stored in the blackboard rather than in the flowdata. By default, the key in the blackboard is set to the node name. To customize the key, specify the out_field parameter. |
out_field | str |
No |
None |
The key for the data in the blackboard. If out_bb is set to False, this parameter is ignored. |
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"