diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/en.md b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/en.md new file mode 100644 index 000000000..3f231110e --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/en.md @@ -0,0 +1,69 @@ +--- +title: Using the built-in function "encoding/csv.Decode" to access CSV data stored as a string +tags: +- commented cue +- encodings +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function `encoding/csv.Decode` to decode a +string containing comma-separated values (CSV) into a list of lists. + +{{{with code "en" "cc"}}} +exec cue export -e output +cmp stdout out +-- file.cue -- +package example + +import "encoding/csv" + +data: """ + Id,Name,Location,Species + 1,Charlie,"Ripon, North Yorkshire",cat + 2,Fred,San Francisco,cat + 3,Greyfriars Bobby,Edinburgh,dog + 4,Nemo,???,fish + """ + +output: csv.Decode(data) +-- out -- +[ + [ + "Id", + "Name", + "Location", + "Species" + ], + [ + "1", + "Charlie", + "Ripon, North Yorkshire", + "cat" + ], + [ + "2", + "Fred", + "San Francisco", + "cat" + ], + [ + "3", + "Greyfriars Bobby", + "Edinburgh", + "dog" + ], + [ + "4", + "Nemo", + "???", + "fish" + ] +] +{{{end}}} + +## Related content + +- The [`encoding/csv`](https://pkg.go.dev/cuelang.org/go/pkg/encoding/csv) built-in package diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/gen_cache.cue b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/gen_cache.cue new file mode 100644 index 000000000..764b88201 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/gen_cache.cue @@ -0,0 +1,18 @@ +package site +{ + content: { + docs: { + howto: { + "use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string": { + page: { + cache: { + code: { + cc: "qb3Ovwt0UuGd59488zDWr8EyBEfjJok2ic1/QIAjP4E=" + } + } + } + } + } + } + } +} diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/page.cue b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/page.cue new file mode 100644 index 000000000..7926ceff2 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/page.cue @@ -0,0 +1,3 @@ +package site + +content: docs: howto: "use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string": {} diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/en.md b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/en.md new file mode 100644 index 000000000..dbdf43ae9 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/en.md @@ -0,0 +1,68 @@ +--- +title: Using the built-in function "encoding/csv.Decode" to access data stored in a CSV file +tags: +- commented cue +- encodings +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function `encoding/csv.Decode` to decode a +file containing comma-separated values (CSV) into a list of lists. + +{{{with code "en" "cc"}}} +exec cue export .:example -l input: text: data.csv -e output +cmp stdout out +-- data.csv -- +Id,Name,Location,Species +1,Charlie,"Ripon, North Yorkshire",cat +2,Fred,San Francisco,cat +3,Greyfriars Bobby,Edinburgh,dog +4,Nemo,???,fish +-- file.cue -- +package example + +import "encoding/csv" + +input: string +output: csv.Decode(input) +-- out -- +[ + [ + "Id", + "Name", + "Location", + "Species" + ], + [ + "1", + "Charlie", + "Ripon, North Yorkshire", + "cat" + ], + [ + "2", + "Fred", + "San Francisco", + "cat" + ], + [ + "3", + "Greyfriars Bobby", + "Edinburgh", + "dog" + ], + [ + "4", + "Nemo", + "???", + "fish" + ] +] +{{{end}}} + +## Related content + +- The [`encoding/csv`](https://pkg.go.dev/cuelang.org/go/pkg/encoding/csv) built-in package diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/gen_cache.cue b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/gen_cache.cue new file mode 100644 index 000000000..1e07a8289 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/gen_cache.cue @@ -0,0 +1,18 @@ +package site +{ + content: { + docs: { + howto: { + "use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file": { + page: { + cache: { + code: { + cc: "Epk34AtMbOXh6Y/RXsfw1bLnFiRVZyXEi/coFHrle2w=" + } + } + } + } + } + } + } +} diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/page.cue b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/page.cue new file mode 100644 index 000000000..4d281f22a --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/page.cue @@ -0,0 +1,3 @@ +package site + +content: docs: howto: "use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file": {} diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/en.md b/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/en.md new file mode 100644 index 000000000..f267a3d74 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/en.md @@ -0,0 +1,43 @@ +--- +title: Using the built-in function "encoding/csv.Encode" to emit CSV data +tags: +- commented cue +- encodings +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function `encoding/csv.Encode` to encode a +list of lists into a string as comma-separated values (CSV). + +{{{with code "en" "cc"}}} +exec cue export -e output --out text +cmp stdout out +-- file.cue -- +package example + +import "encoding/csv" + +data: [ + ["Id", "Name", "Location", "Species"], + ["1", "Charlie", "Ripon, North Yorkshire", "cat"], + ["2", "Fred", "San Francisco", "cat"], + ["3", "Greyfriars Bobby", "Edinburgh", "dog"], + ["4", "Nemo", "???", "fish"], +] + +output: csv.Encode(data) +-- out -- +Id,Name,Location,Species +1,Charlie,"Ripon, North Yorkshire",cat +2,Fred,San Francisco,cat +3,Greyfriars Bobby,Edinburgh,dog +4,Nemo,???,fish + +{{{end}}} + +## Related content + +- The [`encoding/csv`](https://pkg.go.dev/cuelang.org/go/pkg/encoding/csv) built-in package diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/gen_cache.cue b/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/gen_cache.cue new file mode 100644 index 000000000..583c4b188 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/gen_cache.cue @@ -0,0 +1,18 @@ +package site +{ + content: { + docs: { + howto: { + "use-the-built-in-function-encoding-csv-encode-to-emit-csv-data": { + page: { + cache: { + code: { + cc: "Mg2lD5dfuXSK/A2VfdIpOvbj1ontkBweDL3sOQ9HtfY=" + } + } + } + } + } + } + } +} diff --git a/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/page.cue b/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/page.cue new file mode 100644 index 000000000..70645c630 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/page.cue @@ -0,0 +1,3 @@ +package site + +content: docs: howto: "use-the-built-in-function-encoding-csv-encode-to-emit-csv-data": {} diff --git a/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/index.md b/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/index.md new file mode 100644 index 000000000..24cc26bb3 --- /dev/null +++ b/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-csv-data-stored-as-a-string/index.md @@ -0,0 +1,70 @@ +--- +title: Using the built-in function "encoding/csv.Decode" to access CSV data stored as a string +tags: +- commented cue +- encodings +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function `encoding/csv.Decode` to decode a +string containing comma-separated values (CSV) into a list of lists. + +{{< code-tabs >}} +{{< code-tab name="file.cue" language="cue" area="top-left" >}} +package example + +import "encoding/csv" + +data: """ + Id,Name,Location,Species + 1,Charlie,"Ripon, North Yorkshire",cat + 2,Fred,San Francisco,cat + 3,Greyfriars Bobby,Edinburgh,dog + 4,Nemo,???,fish + """ + +output: csv.Decode(data) +{{< /code-tab >}} +{{< code-tab name="TERMINAL" language="" type="terminal" area="top-right" >}} +$ cue export -e output +[ + [ + "Id", + "Name", + "Location", + "Species" + ], + [ + "1", + "Charlie", + "Ripon, North Yorkshire", + "cat" + ], + [ + "2", + "Fred", + "San Francisco", + "cat" + ], + [ + "3", + "Greyfriars Bobby", + "Edinburgh", + "dog" + ], + [ + "4", + "Nemo", + "???", + "fish" + ] +] +{{< /code-tab >}} +{{< /code-tabs >}} + +## Related content + +- The [`encoding/csv`](https://pkg.go.dev/cuelang.org/go/pkg/encoding/csv) built-in package diff --git a/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/index.md b/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/index.md new file mode 100644 index 000000000..0371c97c8 --- /dev/null +++ b/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-decode-to-access-data-stored-in-a-csv-file/index.md @@ -0,0 +1,70 @@ +--- +title: Using the built-in function "encoding/csv.Decode" to access data stored in a CSV file +tags: +- commented cue +- encodings +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function `encoding/csv.Decode` to decode a +file containing comma-separated values (CSV) into a list of lists. + +{{< code-tabs >}} +{{< code-tab name="data.csv" language="csv" area="top-left" >}} +Id,Name,Location,Species +1,Charlie,"Ripon, North Yorkshire",cat +2,Fred,San Francisco,cat +3,Greyfriars Bobby,Edinburgh,dog +4,Nemo,???,fish +{{< /code-tab >}} +{{< code-tab name="file.cue" language="cue" area="top-right" >}} +package example + +import "encoding/csv" + +input: string +output: csv.Decode(input) +{{< /code-tab >}} +{{< code-tab name="TERMINAL" language="" type="terminal" area="bottom" >}} +$ cue export .:example -l input: text: data.csv -e output +[ + [ + "Id", + "Name", + "Location", + "Species" + ], + [ + "1", + "Charlie", + "Ripon, North Yorkshire", + "cat" + ], + [ + "2", + "Fred", + "San Francisco", + "cat" + ], + [ + "3", + "Greyfriars Bobby", + "Edinburgh", + "dog" + ], + [ + "4", + "Nemo", + "???", + "fish" + ] +] +{{< /code-tab >}} +{{< /code-tabs >}} + +## Related content + +- The [`encoding/csv`](https://pkg.go.dev/cuelang.org/go/pkg/encoding/csv) built-in package diff --git a/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/index.md b/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/index.md new file mode 100644 index 000000000..f924d5b49 --- /dev/null +++ b/hugo/content/en/docs/howto/use-the-built-in-function-encoding-csv-encode-to-emit-csv-data/index.md @@ -0,0 +1,44 @@ +--- +title: Using the built-in function "encoding/csv.Encode" to emit CSV data +tags: +- commented cue +- encodings +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function `encoding/csv.Encode` to encode a +list of lists into a string as comma-separated values (CSV). + +{{< code-tabs >}} +{{< code-tab name="file.cue" language="cue" area="top-left" >}} +package example + +import "encoding/csv" + +data: [ + ["Id", "Name", "Location", "Species"], + ["1", "Charlie", "Ripon, North Yorkshire", "cat"], + ["2", "Fred", "San Francisco", "cat"], + ["3", "Greyfriars Bobby", "Edinburgh", "dog"], + ["4", "Nemo", "???", "fish"], +] + +output: csv.Encode(data) +{{< /code-tab >}} +{{< code-tab name="TERMINAL" language="" type="terminal" area="top-right" >}} +$ cue export -e output --out text +Id,Name,Location,Species +1,Charlie,"Ripon, North Yorkshire",cat +2,Fred,San Francisco,cat +3,Greyfriars Bobby,Edinburgh,dog +4,Nemo,???,fish + +{{< /code-tab >}} +{{< /code-tabs >}} + +## Related content + +- The [`encoding/csv`](https://pkg.go.dev/cuelang.org/go/pkg/encoding/csv) built-in package