This Commented CUE
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.
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)
TERMINAL
$ 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"
]
]
Related content
- The
encoding/csv
built-in package