CSV
kind: csv
On this page
source | condition | target |
---|---|---|
✔ | ✔ | ✔ |
Description
source
The CSV "source" retrieves an information from a CSV file.
condition
The CSV "condition" tests that an information exist in a CSV file.
target
The CSV "target" ensures that a CSV file content a specific value at specific location.
Parameters
Name | Type | Description | Required |
---|---|---|---|
comma | integer | [s][c][t] Comma specifies the csv separator character, default “,” | |
comment | integer | [s][c][t] Comma specifies the csv comment character, default “#” | |
file | string | [s][c][t] File specifies the csv file | |
files | array | [c][t] Files specifies a list of Json file to manipulate | |
key | string | [s][c][t] Key specifies the csv query | |
query | string | [s][c][t] Query allows to used advanced query. Override the parameter key | |
value | string | [s][c][t] Key specifies the csv value, default to source output | |
versionfilter | object | [s]VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest. | |
kind | string | specifies the version kind such as semver, regex, or latest | |
pattern | string | specifies the version pattern according the version kind | |
strict | boolean | strict enforce strict versioning rule. Only used for semantic versioning at this time |
Query
The csv resource benefits from the Dasel library https://daseldocs.tomwright.me/
Example
# updatecli.yaml
name: CSV manipulation examples
sources:
default:
name: Basic get query
kind: csv
spec:
file: pkg/plugins/resources/csv/testdata/data.csv
key: .[0].firstname
conditions:
single:
name: Basic condition query
kind: csv
disablesourceinput: true
spec:
file: pkg/plugins/resources/csv/testdata/data.csv
key: .[0].firstname
value: John
targets:
single:
name: Basic target update
kind: csv
spec:
file: pkg/plugins/resources/csv/testdata/data.csv
key: .[1].firstname
value: John
multiple:
name: Multiple target update
kind: csv
spec:
files:
- pkg/plugins/resources/csv/testdata/data1.csv
- pkg/plugins/resources/csv/testdata/data2.csv
query: .[*].firstname
Important
The library used to manipulate CSV files, drops comments. More information is available on
tomwright/dasel#178. Until we find a solution, a potential workaround is to use the resource file
like in the following example: