Documentation
¶
Overview ¶
Package csv contains the csv node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVConfig ¶
type CSVConfig struct {
// Property is the message field to convert; "payload" (default)
// targets msg.Payload, otherwise a dotted path inside the data map
Property string `json:"property"`
// Headers treats the first row as a header line: parsed rows become
// objects keyed by the header names; serializing objects writes a
// header row derived from the first object's keys
Headers bool `json:"headers"`
}
CSVConfig holds configuration for the csv node — a simplified Node-RED CSV parser equivalent.
type CSVNode ¶
CSVNode converts between a CSV string and row data. A string input is parsed and expanded into one message per row (parts metadata, like the split node); an array input is serialized into a CSV string.
func NewCSVNode ¶
func NewCSVNode(node nodestore.NodeInterface, config *CSVConfig) *CSVNode
NewCSVNode creates a new csv node
func (*CSVNode) Execute ¶
func (n *CSVNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute converts the configured property. Strings are parsed and the rows stashed for Expand; slices are serialized to a CSV string and written back to the property.
func (*CSVNode) Expand ¶
func (n *CSVNode) Expand(output nodestore.MessageInterface) []nodestore.MessageInterface
Expand emits one message per parsed row. With headers each row is a map keyed by the header line; otherwise a []string. Every message carries parts metadata (id, type "csv", index, count) so a downstream join node can reassemble the table.