Documentation
¶
Index ¶
- func DecodeAll[S ~[]E, E any](r io.Reader, dest *S) (err error)
- func DecodeFile[S ~[]E, E any](file string, dest *S) error
- func Export[S ~[]E, E any](fieldnames []string, slice S, w io.Writer) error
- func ExportFile[S ~[]E, E any](fieldnames []string, slice S, file string) error
- func ExportUTF8[S ~[]E, E any](fieldnames []string, slice S, w io.Writer) error
- func ExportUTF8File[S ~[]E, E any](fieldnames []string, slice S, file string) error
- type D
- type E
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFile ¶
DecodeFile decodes each record from file into dest.
func ExportFile ¶
ExportFile writes slice as csv format with fieldnames to file.
func ExportUTF8 ¶
ExportUTF8 writes slice as utf8 csv format with fieldnames to writer w.
Types ¶
type D ¶
type D []E
D is an ordered representation of a document. This type should be used when the order of the elements matter.
type Reader ¶
A Reader reads records from a CSV-encoded file.
func (*Reader) Decode ¶
Decode will unmarshal the current record into dest. If column's value is like "[...]", it will be treated as slice.
type Writer ¶
A Writer writes records using CSV encoding.
func (*Writer) SkipWriteFields ¶
func (w *Writer) SkipWriteFields()
func (*Writer) Write ¶
Write writes a single CSV record to w along with any necessary quoting after fieldnames is written. A record is a map of strings or a struct. Writes are buffered, so Flush must eventually be called to ensure that the record is written to the underlying io.Writer.
func (*Writer) WriteAll ¶
WriteAll writes multiple CSV records to w using Write and then calls Flush, returning any error from the Flush.
func (*Writer) WriteFields ¶
WriteFields writes fieldnames to w along with necessary utf8bom bytes. The fields must be a non-zero field struct or a non-zero length string slice, otherwise an error will be return. It can be run only once.