Documentation ¶
Index ¶
- Variables
- func RegisterColumnType(name ColumnType, serier ColumnSerier) error
- type AggregateBy
- type AggregationType
- type Column
- type ColumnOption
- type ColumnOptions
- type ColumnSerier
- type ColumnType
- type DataTable
- func Concat(tables []*DataTable) (*DataTable, error)
- func InnerJoin(tables []*DataTable, on []JoinOn) (*DataTable, error)
- func LeftJoin(tables []*DataTable, on []JoinOn) (*DataTable, error)
- func New(name string) *DataTable
- func OuterJoin(tables []*DataTable, on []JoinOn) (*DataTable, error)
- func RightJoin(tables []*DataTable, on []JoinOn) (*DataTable, error)
- func (t *DataTable) AddColumn(name string, ctyp ColumnType, opt ...ColumnOption) error
- func (dt *DataTable) Aggregate(by ...AggregateBy) (*DataTable, error)
- func (t *DataTable) Append(row ...Row)
- func (t *DataTable) AppendRow(v ...interface{}) error
- func (t *DataTable) Column(name string) Column
- func (t *DataTable) ColumnIndex(name string) int
- func (t *DataTable) Columns() []string
- func (left *DataTable) Concat(table ...*DataTable) (*DataTable, error)
- func (t *DataTable) Copy() *DataTable
- func (t *DataTable) EmptyCopy() *DataTable
- func (dt *DataTable) GroupBy(by ...GroupBy) (*Groups, error)
- func (t *DataTable) Grow(size int)
- func (t *DataTable) Head(size int) *DataTable
- func (t *DataTable) HiddenColumns() []string
- func (t *DataTable) HideAll()
- func (t *DataTable) HideColumn(name string)
- func (left *DataTable) InnerJoin(right *DataTable, on []JoinOn) (*DataTable, error)
- func (left *DataTable) LeftJoin(right *DataTable, on []JoinOn) (*DataTable, error)
- func (t *DataTable) Name() string
- func (t *DataTable) NewRow() Row
- func (t *DataTable) NumCols() int
- func (t *DataTable) NumRows() int
- func (left *DataTable) OuterJoin(right *DataTable, on []JoinOn) (*DataTable, error)
- func (t *DataTable) Print(writer io.Writer, opt ...PrintOption)
- func (t *DataTable) Records() [][]string
- func (t *DataTable) Rename(name string)
- func (t *DataTable) RenameColumn(old, name string) error
- func (left *DataTable) RightJoin(right *DataTable, on []JoinOn) (*DataTable, error)
- func (t *DataTable) Row(at int, opt ...ExportOption) Row
- func (t *DataTable) Rows(opt ...ExportOption) []Row
- func (t *DataTable) ShowAll()
- func (t *DataTable) ShowColumn(name string)
- func (t *DataTable) Sort(by ...SortBy) *DataTable
- func (t *DataTable) String() string
- func (t *DataTable) Subset(at, size int) *DataTable
- func (t *DataTable) SwapColumn(a, b string) error
- func (t *DataTable) SwapRow(i, j int)
- func (t *DataTable) Tail(size int) *DataTable
- func (t *DataTable) ToMap(opt ...ExportOption) []map[string]interface{}
- func (t *DataTable) ToSchema(opt ...ExportOption) *Schema
- func (t *DataTable) ToTable(opt ...ExportOption) [][]interface{}
- func (t *DataTable) Update(at int, row Row) error
- func (t *DataTable) Where(predicate func(row Row) bool) *DataTable
- type ExportOption
- type ExportOptions
- type GroupBy
- type Groups
- type JoinOn
- type PrintOption
- type PrintOptions
- type Row
- type Schema
- type SchemaColumn
- type SortBy
Constants ¶
This section is empty.
Variables ¶
var ( ErrOpenFile = errors.New("open file") ErrCantReadHeaders = errors.New("can't read headers") ErrReadingLine = errors.New("could not read line") ErrNilDatas = errors.New("nil datas") ErrWrongNumberOfTypes = errors.New("expected different number of types") ErrAddingColumn = errors.New("could not add column with given type") )
Errors in import/csv
var ( ErrNoGroupBy = errors.New("no groupby") ErrNoGroups = errors.New("no groups") ErrNilDatatable = errors.New("nil datatable") ErrColumnNotFound = errors.New("column not found") ErrUnknownAgg = errors.New("unknown agg") ErrCantAddColumn = errors.New("can't add column") )
Errors in aggregate.go
var ( ErrEmptyName = errors.New("empty name") ErrNilFactory = errors.New("nil factory") ErrTypeAlreadyExists = errors.New("type already exists") ErrUnknownColumnType = errors.New("unknown column type") )
Errors in column.go
var ( ErrNilOutputDatatable = errors.New("nil output datatable") ErrNoOutput = errors.New("no output") ErrNilTable = errors.New("table is nil") ErrNotEnoughDatatables = errors.New("not enough datatables") ErrNoOnClauses = errors.New("no on clauses") ErrOnClauseIsNil = errors.New("on clause is nil") ErrUnknownMode = errors.New("unknown mode") )
Errors in join.go
var ( ErrNilColumn = errors.New("nil column") ErrNilColumnName = errors.New("nil column name") ErrNilColumnType = errors.New("nil column type") ErrColumnAlreadyExists = errors.New("column already exists") ErrFormulaeSyntax = errors.New("formulae syntax") ErrNilSerie = errors.New("nil serie") ErrCreateSerie = errors.New("create serie") )
Errors in mutate_column.go
var ( ErrLengthMismatch = errors.New("length mismatch") ErrUpdateRow = errors.New("update row") )
Errors in mutate_rows.go
var (
ErrEvaluateExprSizeMismatch = errors.New("size mismatch")
)
Errors in eval_expr
var (
ErrNoTables = errors.New("no tables")
)
Errors in concat.go
Functions ¶
func RegisterColumnType ¶
func RegisterColumnType(name ColumnType, serier ColumnSerier) error
RegisterColumnType to extends the known type
Types ¶
type AggregateBy ¶
type AggregateBy struct { Type AggregationType Field string As string }
AggregateBy defines the aggregation
type AggregationType ¶
type AggregationType uint8
AggregationType defines the avalaible aggregation
const ( Avg AggregationType = iota Count CountDistinct Cusum Max Min Median Stddev Sum Variance )
func (AggregationType) String ¶
func (a AggregationType) String() string
type Column ¶
type Column interface { Name() string Type() ColumnType UnderlyingType() reflect.Type IsVisible() bool IsComputed() bool }
Column describes a column in our datatable
type ColumnOption ¶
type ColumnOption func(opts *ColumnOptions)
ColumnOption sets column options
func Expr ¶
func Expr(v string) ColumnOption
Expr sets the expr for the column <!> Incompatible with ColumnValues
func TimeFormats ¶
func TimeFormats(v ...string) ColumnOption
TimeFormats sets the valid time formats. <!> Only for Time Column
func Values ¶
func Values(v ...interface{}) ColumnOption
Values fills the column with the values <!> Incompatible with ColumnExpr
type ColumnOptions ¶
ColumnOptions describes options to be apply on a column
type ColumnSerier ¶
type ColumnSerier func(ColumnOptions) serie.Serie
ColumnSerier to create a serie from column options
type ColumnType ¶
type ColumnType string
ColumnType defines the valid column type in datatable
const ( Bool ColumnType = "bool" String ColumnType = "string" Int ColumnType = "int" // Int8 ColumnType = "int8" // Int16 ColumnType = "int16" Int32 ColumnType = "int32" Int64 ColumnType = "int64" // Uint ColumnType = "uint" // Uint8 ColumnType = "uint8" // Uint16 ColumnType = "uint16" // Uint32 ColumnType = "uint32" // Uint64 ColumnType = "uint64" Float32 ColumnType = "float32" Float64 ColumnType = "float64" Time ColumnType = "time" Raw ColumnType = "raw" )
type DataTable ¶
type DataTable struct {
// contains filtered or unexported fields
}
DataTable is our main struct
func InnerJoin ¶
InnerJoin selects records that have matching values in both tables. tables[0] is used as reference datatable.
func (*DataTable) AddColumn ¶
func (t *DataTable) AddColumn(name string, ctyp ColumnType, opt ...ColumnOption) error
AddColumn to datatable with a serie of T
func (*DataTable) Aggregate ¶
func (dt *DataTable) Aggregate(by ...AggregateBy) (*DataTable, error)
Aggregate aggregates some field
func (*DataTable) ColumnIndex ¶
ColumnIndex gets the index of the column with name returns -1 if not found
func (*DataTable) HiddenColumns ¶
HiddenColumns returns the hidden column names in datatable
func (*DataTable) HideAll ¶
func (t *DataTable) HideAll()
HideAll to hides all column a hidden column will not be exported
func (*DataTable) HideColumn ¶
HideColumn hides a column a hidden column will not be exported
func (*DataTable) InnerJoin ¶
InnerJoin selects records that have matching values in both tables. left datatable is used as reference datatable. <!> InnerJoin transforms an expr column to a raw column
func (*DataTable) LeftJoin ¶
LeftJoin returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match. <!> LeftJoin transforms an expr column to a raw column
func (*DataTable) OuterJoin ¶
OuterJoin returns all records when there is a match in either left or right table <!> OuterJoin transforms an expr column to a raw column
func (*DataTable) Print ¶
func (t *DataTable) Print(writer io.Writer, opt ...PrintOption)
Print the tables with options
func (*DataTable) Records ¶
Records returns the rows in datatable as string Computes all expressions.
func (*DataTable) RenameColumn ¶
RenameColumn to rename a column
func (*DataTable) RightJoin ¶
RightJoin returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match. <!> RightJoin transforms an expr column to a raw column
func (*DataTable) Row ¶
func (t *DataTable) Row(at int, opt ...ExportOption) Row
Row gets the row at index
func (*DataTable) Rows ¶
func (t *DataTable) Rows(opt ...ExportOption) []Row
Rows returns the rows in datatable Computes all expressions.
func (*DataTable) ShowAll ¶
func (t *DataTable) ShowAll()
ShowAll to show all column a shown column will be exported
func (*DataTable) ShowColumn ¶
ShowColumn shows a column a shown column will be exported
func (*DataTable) SwapColumn ¶
SwapColumn to swap 2 columns
func (*DataTable) ToMap ¶
func (t *DataTable) ToMap(opt ...ExportOption) []map[string]interface{}
ToMap to export the datatable to a json-like struct
func (*DataTable) ToSchema ¶
func (t *DataTable) ToSchema(opt ...ExportOption) *Schema
ToSchema to export the datatable to a schema struct
func (*DataTable) ToTable ¶
func (t *DataTable) ToTable(opt ...ExportOption) [][]interface{}
ToTable to export the datatable to a csv-like struct
type ExportOption ¶
type ExportOption func(*ExportOptions)
func ExportHidden ¶
func ExportHidden(v bool) ExportOption
ExportHidden to show a column when exporting (default false)
type ExportOptions ¶
type ExportOptions struct {
WithHiddenCols bool
}
ExportOptions to add options for exporting (like showing hidden columns)
type GroupBy ¶
type GroupBy struct { Name string Type ColumnType Keyer func(row Row) (interface{}, bool) }
GroupBy defines the group by configuration Name is the name of the output column Type is the type of the output column Keyer is our main function to aggregate
type JoinOn ¶
type PrintOption ¶
type PrintOption func(opts *PrintOptions)
func PrintColumnName ¶
func PrintColumnName(v bool) PrintOption
func PrintColumnType ¶
func PrintColumnType(v bool) PrintOption
func PrintMaxRows ¶
func PrintMaxRows(v int) PrintOption
func PrintRowNumber ¶
func PrintRowNumber(v bool) PrintOption
type PrintOptions ¶
PrintOptions to control the printer
type Row ¶
type Row map[string]interface{}
Row contains a row relative to columns
type Schema ¶
type Schema struct { Name string `json:"name"` Columns []SchemaColumn `json:"cols"` Rows [][]interface{} `json:"rows"` }
Schema describes a datatable