Documentation
¶
Overview ¶
Package core implements the CSV decoding and encoding primitives shared by the CSV module wrappers.
Index ¶
- Variables
- func ConvertValue(raw string, opts Options) runtime.Value
- func Decode(ctx context.Context, data runtime.String, opts Options) (runtime.Value, error)
- func DecodeRows(ctx context.Context, data runtime.String, opts Options) (runtime.Value, error)
- func ResolveContent(input runtime.Value) (runtime.String, error)
- func ResolveHeaders(firstRow []string, opts Options) ([]string, bool, error)
- type DecodeIterator
- type DecodeRowsIterator
- type EncodeResult
- type Error
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrHeaderColumnConflict = errors.New("csv: cannot specify both header: true and columns option")
ErrHeaderColumnConflict reports that both a header row and explicit columns were requested at the same time.
Functions ¶
func ConvertValue ¶
ConvertValue converts a decoded CSV field to the runtime representation requested by opts.
func DecodeRows ¶
DecodeRows eagerly decodes CSV text into an array of row arrays.
func ResolveContent ¶
ResolveContent normalizes supported CSV content input to a runtime.String. It accepts only runtime.String and runtime.Binary values.
Types ¶
type DecodeIterator ¶
type DecodeIterator struct {
// contains filtered or unexported fields
}
DecodeIterator iterates over decoded CSV objects. The iterator key is the original 1-based CSV record number after parsing.
func NewDecodeIterator ¶
func NewDecodeIterator(data runtime.String, opts Options) (*DecodeIterator, error)
NewDecodeIterator returns an iterator over decoded CSV objects.
type DecodeRowsIterator ¶
type DecodeRowsIterator struct {
// contains filtered or unexported fields
}
DecodeRowsIterator iterates over decoded CSV rows. The iterator key is the original 1-based CSV record number after parsing.
func NewDecodeRowsIterator ¶
func NewDecodeRowsIterator(data runtime.String, opts Options) (*DecodeRowsIterator, error)
NewDecodeRowsIterator returns an iterator over decoded CSV rows.
type EncodeResult ¶
type EncodeResult struct {
// Text is the encoded CSV output.
Text string
// Rows is the number of data rows written, excluding any generated header.
Rows int
}
EncodeResult contains the encoded CSV text and the number of data rows written.
type Error ¶
Error reports a CSV-specific error with optional row and column context.
type Options ¶
type Options struct {
Delimiter string `json:"delimiter"`
Comment string `json:"comment"`
Columns []string `json:"columns"`
NullValues []string `json:"nullValues"`
Header bool `json:"header"`
Trim bool `json:"trim"`
SkipEmpty bool `json:"skipEmpty"`
Strict bool `json:"strict"`
InferTypes bool `json:"inferTypes"`
}
Options configures CSV decoding and encoding behavior.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns the default CSV options used by the module.
func (*Options) ApplyToReader ¶
ApplyToReader applies the reader-supported options to r.