Documentation
¶
Overview ¶
Package data provides parsers for common data formats
Package data provides data pipeline operations ¶
Package data provides structured data processing capabilities for cbwsh. Inspired by modern shells like Nushell and PowerShell, this package enables type-safe data pipelines and native support for common data formats.
Index ¶
- type CSVParser
- type DataType
- type Formatter
- type JSONFormatter
- type JSONParser
- type Operation
- type Parser
- type Pipeline
- func (p *Pipeline) Execute() *Table
- func (p *Pipeline) GroupBy(field string) *Pipeline
- func (p *Pipeline) Limit(n int) *Pipeline
- func (p *Pipeline) Select(columns ...string) *Pipeline
- func (p *Pipeline) Sort(field string, ascending bool) *Pipeline
- func (p *Pipeline) Where(field string, condition func(*Value) bool) *Pipeline
- type Record
- type Table
- type TableFormatter
- type Value
- type YAMLParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVParser ¶
CSVParser parses CSV data into structured tables
type DataType ¶
type DataType string
DataType represents the type of structured data
const ( // DataTypeString represents string data DataTypeString DataType = "string" // DataTypeInt represents integer data DataTypeInt DataType = "int" // DataTypeFloat represents floating point data DataTypeFloat DataType = "float" // DataTypeBool represents boolean data DataTypeBool DataType = "bool" // DataTypeArray represents array/list data DataTypeArray DataType = "array" // DataTypeObject represents object/map data DataTypeObject DataType = "object" // DataTypeNull represents null/nil data DataTypeNull DataType = "null" // DataTypeTime represents time/date data DataTypeTime DataType = "time" )
type JSONFormatter ¶
type JSONFormatter struct {
Pretty bool
}
JSONFormatter formats a table as JSON
func NewJSONFormatter ¶
func NewJSONFormatter(pretty bool) *JSONFormatter
NewJSONFormatter creates a new JSON formatter
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(table *Table) string
Format formats a table as JSON
type JSONParser ¶
type JSONParser struct{}
JSONParser parses JSON data into structured tables
func (*JSONParser) Parse ¶
func (p *JSONParser) Parse(data []byte) (*Table, error)
Parse parses JSON bytes into a table
func (*JSONParser) ParseReader ¶
func (p *JSONParser) ParseReader(r io.Reader) (*Table, error)
ParseReader parses JSON from a reader into a table
type Parser ¶
type Parser interface {
Parse(data []byte) (*Table, error)
ParseReader(r io.Reader) (*Table, error)
}
Parser is an interface for parsing data formats
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline represents a data transformation pipeline
func NewPipeline ¶
NewPipeline creates a new data pipeline with the given table
type Record ¶
Record represents a single record in a structured data stream Similar to a row in a table or a JSON object
type Table ¶
Table represents a collection of records (like a database table)
type TableFormatter ¶
type TableFormatter struct {
MaxCellWidth int
}
TableFormatter formats a table as a text table
func NewTableFormatter ¶
func NewTableFormatter() *TableFormatter
NewTableFormatter creates a new table formatter
func (*TableFormatter) Format ¶
func (f *TableFormatter) Format(table *Table) string
Format formats a table as a text table
type Value ¶
type Value struct {
Type DataType `json:"type"`
Data interface{} `json:"data"`
}
Value represents a typed value in the data pipeline
type YAMLParser ¶
type YAMLParser struct{}
YAMLParser parses YAML data into structured tables
func (*YAMLParser) Parse ¶
func (p *YAMLParser) Parse(data []byte) (*Table, error)
Parse parses YAML bytes into a table
func (*YAMLParser) ParseReader ¶
func (p *YAMLParser) ParseReader(r io.Reader) (*Table, error)
ParseReader parses YAML from a reader into a table