Flat File Document

Delimited flat files store tabular records as rows and columns separated by configurable characters.

The Flowgear Flat File Document Node parses a delimited document into JSON rows or creates a delimited document from JSON rows.

Revision History

0.2.0.14 - Current release.
0.0.0.4 - Initial release.
0.0.0.11 - Current release.
0.2.0.15 - Updated the Node icon.

Setup Notes

  • Delimiter values accept escaped characters such as \r, \n, \t, and \\.

Methods

Parse

Reads a delimited flat file document and returns one JSON object for each row.

Use this method when you need to turn a flat file into rows that downstream Steps can process one at a time.

Parameter Type Description
Document Stream The flat-file document to parse.
Options Object Options that control how the flat-file content is parsed.
Options.RowDelimiter String The row delimiter. The default is \r\n.
Options.ColumnDelimiter String The column delimiter. The default is ,.
Options.FirstRowContainsColumnHeaders Boolean When true, the first row is treated as column headers. The default is true.
Return Type Description
Rows Array One JSON object for each parsed row.

Create

Renders a list of JSON objects as a delimited flat file document.

The column order in the rendered flat file document is taken from the first JSON object in Items. Properties that only appear in later items are not added as new columns.

Parameter Type Description
Items Array The JSON rows to write to the document. Each item should be a JSON object.
Options Object Options that control how the JSON rows are rendered.
Options.RowDelimiter String The row delimiter to write. The default is \r\n.
Options.ColumnDelimiter String The column delimiter to write. The default is ,.
Options.FirstRowContainsColumnHeaders Boolean When true, the first output row contains column headers. The default is true.
Return Type Description
Document Stream The rendered flat file document.

Usage Notes

  • When FirstRowContainsColumnHeaders is true, the first row becomes the property names in each returned JSON row.
  • If the file has duplicate header names, this Node makes them unique by appending a numeric suffix such as Thing2 and Thing3.
  • If a data row has more cells than the header row, extra values are returned with generated names such as Column3.
  • If FirstRowContainsColumnHeaders is false, every row is treated as data and columns are named Column1, Column2, and so on.
  • Nested JSON values are not expanded into columns. Objects are written as (object) and arrays are written as (array).

Known Issues

  • This Node only handles delimited flat files. Fixed-width parsing and rendering are current not supported.
  • Parse currently supports the default Windows row format of \r\n. Other row delimiters are not supported for parsing.