CSV

kind: csv

sourceconditiontarget

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

NameTypeDescriptionRequired
commainteger[s][c][t] Comma specifies the csv separator character, default “,”
commentinteger[s][c][t] Comma specifies the csv comment character, default “#”
filestring[s][c][t] File specifies the csv file
filesarray[c][t] Files specifies a list of Json file to manipulate
keystring[s][c][t] Key specifies the csv query
querystring[s][c][t] Query allows to used advanced query. Override the parameter key
valuestring[s][c][t] Key specifies the csv value, default to source output
versionfilterobject[s]VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.
kindstringspecifies the version kind such as semver, regex, or latest
patternstringspecifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format
regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
replaceallobjectreplaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction.
strictbooleanstrict 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:

Top

AltStyle によって変換されたページ (->オリジナル) /