Documentation
¶
Index ¶
- func Columns(r Row) ([]string, error)
- func Flatten(r Row) []types.Value
- func Length(r Row) (int, error)
- func MarshalJSON(r Row) ([]byte, error)
- func MarshalTextIndent(r Row, prefix, indent string) ([]byte, error)
- func NewValue(x any) (types.Value, error)
- type Column
- type ColumnBuffer
- func (cb *ColumnBuffer) Add(column string, v types.Value) *ColumnBuffer
- func (cb *ColumnBuffer) Copy(r Row) error
- func (cb *ColumnBuffer) Delete(column string) error
- func (cb ColumnBuffer) Get(column string) (types.Value, error)
- func (cb ColumnBuffer) Iterate(fn func(column string, value types.Value) error) error
- func (cb ColumnBuffer) Len() int
- func (cb *ColumnBuffer) MarshalJSON() ([]byte, error)
- func (cb *ColumnBuffer) Replace(column string, v types.Value) error
- func (cb *ColumnBuffer) Reset()
- func (cb *ColumnBuffer) ScanCSV(headers, columns []string)
- func (cb *ColumnBuffer) Set(column string, v types.Value) error
- func (cb *ColumnBuffer) UnmarshalJSON(data []byte) error
- type Row
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ColumnBuffer ¶
type ColumnBuffer struct {
// contains filtered or unexported fields
}
ColumnBuffer stores a group of columns in memory. It implements the Row interface.
func (*ColumnBuffer) Add ¶
func (cb *ColumnBuffer) Add(column string, v types.Value) *ColumnBuffer
Add a field to the buffer.
func (*ColumnBuffer) Copy ¶
func (cb *ColumnBuffer) Copy(r Row) error
Copy every value of the row to the buffer.
func (*ColumnBuffer) Delete ¶
func (cb *ColumnBuffer) Delete(column string) error
Delete a column from the buffer.
func (ColumnBuffer) Get ¶
func (cb ColumnBuffer) Get(column string) (types.Value, error)
Get returns a value by column. Returns an error if the column doesn't exists.
func (ColumnBuffer) Iterate ¶
Iterate goes through all the columns of the row and calls the given function by passing each one of them. If the given function returns an error, the iteration stops.
func (*ColumnBuffer) MarshalJSON ¶
func (cb *ColumnBuffer) MarshalJSON() ([]byte, error)
func (*ColumnBuffer) Replace ¶
func (cb *ColumnBuffer) Replace(column string, v types.Value) error
Replace the value of the column by v.
func (*ColumnBuffer) ScanCSV ¶
func (cb *ColumnBuffer) ScanCSV(headers, columns []string)
func (*ColumnBuffer) Set ¶
func (cb *ColumnBuffer) Set(column string, v types.Value) error
Set replaces a column if it already exists or creates one if not.
func (*ColumnBuffer) UnmarshalJSON ¶
func (cb *ColumnBuffer) UnmarshalJSON(data []byte) error
type Row ¶
type Row interface {
// Iterate goes through all the columns of the row and calls the given function
// by passing the column name
Iterate(fn func(column string, value types.Value) error) error
// Get returns the value of the given column.
// If the column does not exist, it returns ErrColumnNotFound.
Get(name string) (types.Value, error)
}
func NewFromCSV ¶
NewFromCSV takes a list of headers and columns and returns an row. Each header will be assigned as the key and each corresponding column as a text value. The length of headers and columns must be the same.