richframe

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

README

RichFrame

gota provide a DataFrame impletation framework for Golang. I just need some methods to handle []map<string>interface{}, so I create RichFrame that can do some work like DataFrame.

You can view the *_test.go to get the usage. It's easy and directly.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportRichFrames

func ExportRichFrames(data map[string]RichFrame, outExcelFile, excelDefFile string, opts *Options) error

func ExportRichFramesByTemp added in v1.0.3

func ExportRichFramesByTemp(data map[string]RichFrame, outExcelFile, tmpExcelFile, excelDefFile string, opts *Options) error

func ExportToFile

func ExportToFile(data map[string][]map[string]interface{}, outExcelFile, excelDefFile string, opts *Options) error

func LoadFromFile

func LoadFromFile(excelFile, excelDefFile string, opts *Options) (map[string]RichFrame, error)

func LoadRichFrames

func LoadRichFrames(excelFile, excelDefFile string, opts *Options) (map[string]RichFrame, error)

func LoadXlsxFileDef

func LoadXlsxFileDef(in io.Reader, def *XlsxFileDef) error

func Marshal

func Marshal(outFilePath string, input interface{}, def *XlsxFileDef) error

func MarshalByTemp added in v1.0.3

func MarshalByTemp(outFilePath, tmpExcelFile string, input interface{}, def *XlsxFileDef) error

func MatchGroup

func MatchGroup(left RichMap, right RichMap, leftBys []string, rightBys []string) bool

func ParseExcelDate

func ParseExcelDate(valueStr string, ops interface{}) (interface{}, error)

func ParseFloat

func ParseFloat(valueStr string, ops interface{}) (interface{}, error)

func ParseInt

func ParseInt(valueStr string, ops interface{}) (interface{}, error)

func ParseString

func ParseString(valueStr string, ops interface{}) (interface{}, error)

func PrepareRow

func PrepareRow(values []string, columns *Columns) map[string]interface{}

func SaveCSV added in v1.0.2

func SaveCSV(csvpath string, rf RichFrame, keys []string, isAppend bool) error

func Unmarshal

func Unmarshal(xslxFile string, result interface{}, def *XlsxFileDef, opts *Options) error

Types

type AggregateFunc

type AggregateFunc func(interface{}, RichMap) interface{}

type ApplyFunc

type ApplyFunc func(RichMap)

type Columns

type Columns struct {
	FieldDefs map[int]*FieldDef
}

func PrepareColumns

func PrepareColumns(titles []string, sheetDef *SheetDef) *Columns

func (*Columns) AddColumns

func (columns *Columns) AddColumns(index int, fieldDef *FieldDef)

func (*Columns) GetFieldDef

func (columns *Columns) GetFieldDef(index int) *FieldDef

type CompareFunc added in v1.0.1

type CompareFunc func(RichMap, RichMap) int

type FieldDef

type FieldDef struct {
	Key        string   `json:"key"`
	Index      int      `json:"index"`
	Aliases    []string `json:"aliases"`
	DataType   string   `json:"dataType"`
	DataOption string   `json:"dataOption"`
}

func (*FieldDef) GetTitle

func (fieldDef *FieldDef) GetTitle() string

func (*FieldDef) ParseValue

func (fieldDef *FieldDef) ParseValue(valueStr string) (interface{}, error)

func (*FieldDef) ValidAlias

func (fieldDef *FieldDef) ValidAlias(name string) bool

type FilterFunc

type FilterFunc func(RichMap) bool

type MutateFunc

type MutateFunc func(RichMap) interface{}

type Options

type Options struct {
}

type ParseDataFunc

type ParseDataFunc func(valueStr string, ops interface{}) (interface{}, error)

type ParseDataFuncFactory

type ParseDataFuncFactory struct {
	ParseDataFuncs map[string]ParseDataFunc
}
var ParseDataFuncs *ParseDataFuncFactory

func GetParseDataFuncFactory

func GetParseDataFuncFactory() *ParseDataFuncFactory

func (*ParseDataFuncFactory) AddFunc

func (factory *ParseDataFuncFactory) AddFunc(dataType string, pdFunc ParseDataFunc)

func (*ParseDataFuncFactory) Get

func (factory *ParseDataFuncFactory) Get(dataType string) ParseDataFunc

type RichFrame

type RichFrame []RichMap

func LoadCSV added in v1.0.2

func LoadCSV(csvpath string, keys []string) (RichFrame, error)

func (RichFrame) Aggregate

func (rf RichFrame) Aggregate(groupBy []string, cols []string, funcs []AggregateFunc) RichFrame

func (RichFrame) Apply

func (rf RichFrame) Apply(f ApplyFunc) RichFrame

func (RichFrame) Col

func (rf RichFrame) Col(col string) []interface{}

func (RichFrame) Del added in v1.0.5

func (rf RichFrame) Del(old string) RichFrame

func (RichFrame) Distinct

func (rf RichFrame) Distinct(col string) []interface{}

func (RichFrame) Filter

func (rf RichFrame) Filter(f FilterFunc) RichFrame

func (RichFrame) Join

func (rf RichFrame) Join(rights RichFrame, leftBys []string, rightBys []string, defaults map[string]interface{})

func (RichFrame) Mutate

func (rf RichFrame) Mutate(title string, f MutateFunc) RichFrame

func (RichFrame) OrderByInt added in v1.0.1

func (rf RichFrame) OrderByInt(rowKey string) RichFrame

func (RichFrame) Rename

func (rf RichFrame) Rename(old string, new string) RichFrame

func (RichFrame) Sort added in v1.0.1

func (rf RichFrame) Sort(f CompareFunc) RichFrame

func (RichFrame) String

func (rf RichFrame) String() string

func (RichFrame) Unique added in v1.0.4

func (rf RichFrame) Unique(col string) RichFrame

type RichMap

type RichMap map[string]interface{}

func GetMatchRichMap

func GetMatchRichMap(left RichMap, rights []RichMap, leftBys []string, rightBys []string) RichMap

type SheetDef

type SheetDef struct {
	Key       string      `json:"key"`
	Aliases   []string    `json:"aliases"`
	FieldDefs []*FieldDef `json:"fields"`
}

func (*SheetDef) GetFieldDef

func (sheetDef *SheetDef) GetFieldDef(name string) *FieldDef

func (*SheetDef) GetTitle

func (sheetDef *SheetDef) GetTitle() string

func (*SheetDef) ValidAlias

func (sheetDef *SheetDef) ValidAlias(name string) bool

type XlsxFileDef

type XlsxFileDef struct {
	SheetDefs []*SheetDef `json:"sheets"`
}

func (*XlsxFileDef) GetSheetDef

func (file *XlsxFileDef) GetSheetDef(name string) *SheetDef

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL