Skip to content

CSV decoder ​

Splits CSV text into records: every line becomes one record of a flow type generated from the configured header names, all properties being strings. Input is a text record or a file stream.

Pins ​

PinKindTypesDescription
InputinputViaducta.Plugins.TextPlugin.Types.TextRecord, Viaducta.Plugins.Files.Types.ViaFileStreamCSV content (TextRecord.Value or the stream).
Outputoutputgenerated <flow namespace>.<OutputTypeName>Called once per decoded line.
Continuecontinue outputany (the input)Called with the input after all lines are decoded.

Configuration ​

FieldTypeDefaultDescription
HeadersstringRequired. Property names, comma-separated without spaces (Id,Name,Price). Each must be a valid identifier. Triggers reconfigure.
Encodingdropdown: UTF8, UTF7, UTF32, ASCIIUTF8Encoding of stream input.
FirstLineIsHeadersbooleanfalsetrue skips the first line.
ColumnSeparatorstring,Column separator, may be several characters; escapes like \t are allowed.
LineSeparatorstring\nLine separator with escapes (\n, \r\n).
UseQuotesbooleantruetrue recognizes quoted values; false reads quote characters as ordinary text.
QuoteCharactersstring"Quote character; only the first character is used. A doubled quote inside a quoted value is an escaped quote.
SkipEmptyLinesbooleantruetrue ignores empty lines; false emits them as records with empty values.
TrimStrategydropdown: 0 None, 1 Start, 2 End, 3 StartAndEnd0Trimming of spaces and tabs around values (see Notes).
OutputTypeNamestring (identifier)Required. Name of the generated record type.
BatchModedropdown: 1 Auto, 2 Always, 3 Never1Whether the records decoded from one input form a batch for batch consumers (Write file, Bulk insert, Build array, ...). Auto: only if the input is not already in a batch; inside a batch (e.g. a file read by Read file) the records stay in that batch. Always: a child batch per input (label = file or text record name). Never: no batch.

Behaviour ​

  • Reconfigure (changing Headers) creates the type OutputTypeName in the flow namespace with one String property per header, in header order, and sets it on Output. Set OutputTypeName first: changing it alone does not regenerate the type; edit Headers again afterwards.
  • Values are assigned by position: column 1 to the first header, and so on. Extra columns are ignored, missing ones stay null. Header names in the file are not used for mapping.
  • One output record per line. When a batch is opened (BatchMode) it ends after the last record was processed downstream: consumers commit then; an error that reaches the decoder fails the batch.
  • After the last line (and the batch end) Continue is called with the input.

Notes ​

  • Lines are split before quotes are evaluated: a line separator inside a quoted value breaks the record.
  • TrimStrategy 1 (Start) trims both ends and 2 (End) trims nothing; use 3 for both ends.
  • With LineSeparator \n on Windows files the last column keeps a trailing \r (trimming only removes spaces and tabs); use \r\n for such files.
  • Header names must not contain spaces after commas (Id, Name fails validation).
  • Whole input is loaded into memory; for memory streams the internal buffer is read, which may contain unused bytes after the content.
  • All values are strings; convert types with a Data mapper.

Example ​

json
{ "Headers": "Id,Name,Price", "OutputTypeName": "PriceRow", "FirstLineIsHeaders": true, "ColumnSeparator": ";", "LineSeparator": "\\r\\n", "TrimStrategy": 3 }

File reader → CSV decoder → Data mapper → Table writer

Viaducta documentation