diff --git a/examples/sample_objects.csv b/examples/sample_objects.csv new file mode 100644 index 00000000..7059b75d --- /dev/null +++ b/examples/sample_objects.csv @@ -0,0 +1,3 @@ +name,numberOfCats,likesApples,height +Gary,1,true,168.8 +Samantha's Rabbit,2,false,-188.8 \ No newline at end of file diff --git a/pkg/yqlib/decoder.go b/pkg/yqlib/decoder.go index adbb0e55..e8c63bf7 100644 --- a/pkg/yqlib/decoder.go +++ b/pkg/yqlib/decoder.go @@ -34,9 +34,9 @@ func InputFormatFromString(format string) (InputFormat, error) { return PropertiesInputFormat, nil case "json", "ndjson", "j": return JsonInputFormat, nil - case "csv": + case "csv", "c": return CSVObjectInputFormat, nil - case "tsv": + case "tsv", "t": return TSVObjectInputFormat, nil default: return 0, fmt.Errorf("unknown format '%v' please use [yaml|xml|props]", format) diff --git a/pkg/yqlib/doc/usage/csv-tsv.md b/pkg/yqlib/doc/usage/csv-tsv.md index fb4b6c30..d02bc143 100644 --- a/pkg/yqlib/doc/usage/csv-tsv.md +++ b/pkg/yqlib/doc/usage/csv-tsv.md @@ -1,3 +1,6 @@ +# CSV +Encode (arrays of arrays) data structures to CSV or TSV, Decode CSV, TSV into an array of objects. + {% hint style="warning" %} Note that versions prior to 4.18 require the 'eval/e' command to be specified. diff --git a/pkg/yqlib/doc/usage/headers/csv-tsv.md b/pkg/yqlib/doc/usage/headers/csv-tsv.md new file mode 100644 index 00000000..740daa6e --- /dev/null +++ b/pkg/yqlib/doc/usage/headers/csv-tsv.md @@ -0,0 +1,3 @@ +# CSV +Encode (arrays of arrays) data structures to CSV or TSV, Decode CSV, TSV into an array of objects. + diff --git a/pkg/yqlib/doc/usage/headers/properties.md b/pkg/yqlib/doc/usage/headers/properties.md index c0c1910e..b3407e2b 100644 --- a/pkg/yqlib/doc/usage/headers/properties.md +++ b/pkg/yqlib/doc/usage/headers/properties.md @@ -1,5 +1,5 @@ # Properties -Encode to a property file (decode not yet supported). Line comments on value nodes will be copied across. +Encode/Decode to/from a property file. Line comments on value nodes will be copied across. By default, empty maps and arrays are not encoded - see below for an example on how to encode a value for these. diff --git a/pkg/yqlib/doc/usage/properties.md b/pkg/yqlib/doc/usage/properties.md index 1b0f3904..b7e8eb58 100644 --- a/pkg/yqlib/doc/usage/properties.md +++ b/pkg/yqlib/doc/usage/properties.md @@ -1,6 +1,6 @@ # Properties -Encode to a property file (decode not yet supported). Line comments on value nodes will be copied across. +Encode/Decode to/from a property file. Line comments on value nodes will be copied across. By default, empty maps and arrays are not encoded - see below for an example on how to encode a value for these.