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"`
// HdrIn is Node-RED's header flag (serialized "hdrin"); same effect
// as Headers
HdrIn bool `json:"hdrin"`
// HdrOut controls header emission when serializing (serialized
// "hdrout"): "none" (default) never emits a header row, "all" emits
// one on every output, "once" emits one until a message carrying a
// reset property arrives
HdrOut string `json:"hdrout"`
// Temp is the column-name template (serialized "temp"): a
// separator-delimited list of column names used to key parsed rows
// and to select/order columns when serializing objects
Temp string `json:"temp"`
// Multi is Node-RED's output mode (serialized "multi"): "one"
// emits one message per row as a parts sequence; "mult" produces a
// single message whose payload is the whole parsed table. Unset
// keeps the nodebase expansion behavior (one message per row).
Multi string `json:"multi"`
// Sep is the column separator (serialized "sep"); default ","
Sep string `json:"sep"`
// Ret is the row terminator hint (serialized "ret", e.g. "\n");
// informational only — the parser accepts both endings
Ret string `json:"ret"`
// Skip skips this many leading lines before parsing (serialized "skip")
Skip int `json:"skip"`
// Strings is Node-RED's "strings" flag: true (and unset) coerces
// numeric-looking cells to numbers via parseFloat
Strings *bool `json:"strings"`
}
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 ¶
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. Each row is an object keyed by the resolved column names — the header row, the configured template, message-provided columns, or generated col1..colN. Every message carries parts metadata (id, type "csv", index, count) so a downstream join node can reassemble the table.