Nodes/ComfyUI CV/CV Array To Text
ComfyUI Node

CV Array To Text

Get your measurements out of the graph and into a file

By bmad4ever·Created 3 months ago·Updated 14 days ago· 1
CV Array To Text
  • nparray
  • text
  • rows
  • truncated
◄format▾►
◄decimals4►
◄header►
◄max_elements100000►

You measured something - camera intrinsics, a CCM matrix, a flow field, per-frame quality scores - and now you want to see it. CV Array To Text formats an array as a text table: CSV, TSV, plain rows, or nested JSON. It's the exit door for numbers, the counterpart to the pack's Parse Matrix node that reads one back in.

Why you'd reach for it

  • Read the numbers. Wire text into core Preview as Text and you have an inspector for any array in the graph. This is how you check that CV Get CCM Matrix actually returned the matrix you think it did, or what shape a flow field really has.
  • Write a file. The pack deliberately ships no file picker here - its own note is that the helper pack already does disk IO - so the intended pairing is Basic Data Handling's save STRING to file. text is a plain string; the CSV/TSV formats are what you want if the destination is a spreadsheet or a script.
  • Round-trip a table. Save it, read it back with Parse Matrix, plot it or re-measure against it. That's why decimals has a -1 setting.
  • Feed a chart. The JSON format is a nested list, which core's Extract Text from JSON and the chart nodes can consume directly.

The inputs that matter

  • nparray - the array. 1-D becomes one row; 2-D becomes one row per row; anything higher is flattened to (-1, last axis) for the table formats and kept fully nested for JSON.
  • format - the output flavour. CSV, TSV and plain emit one line per row with the chosen separator, and Parse Matrix reads all three back. JSON emits a nested list for machines.
  • decimals - digits after the decimal point for float arrays, default 4. -1 prints full repeatable precision (17 digits) - use it when the text is a round trip, not a report. Integer arrays always print exactly, so a label table isn't affected by this at all.
  • header (optional) - comma-separated column names written as the first line, table formats only. Keep it ASCII: the tooltip's reason is real and specific - workflow JSON is read with the Windows codepage, so a non-ASCII header is a portability bug waiting to happen.
  • max_elements (optional) - a cap, default 100 000. Formatting a whole image would produce a multi-megabyte string that the UI has to carry around; the cap is what stops one careless connection from doing that.

Outputs: text - the formatted table, newline-separated with no trailing newline, deliberately, so Parse Matrix reads it back unchanged. rows - data rows written, excluding the header. truncated - true when max_elements cut the output short.

Why truncated deserves to be wired

It's the honest flag in this node, and it's easy to ignore. If it's true, the text is incomplete and must not be round-tripped - you'll write a partial matrix and read a partial matrix back, and nothing in the pipeline will tell you the difference between "my measurement changed" and "my table got cut at 100 000 values". Wire it into a Preview as Text alongside, or into whatever gate your workflow has, and check it once when you set the node up.

Compared to the other inspector

The pack has two nodes that could be mistaken for each other. Inspect CV Data summarises - shape, dtype, statistics - and is what you want when the question is "what is this array?". This node emits every value and is what you want when the question is "what are the numbers?". Use the summary first, then format when you actually need the data.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv

then restart ComfyUI, or install from ComfyUI Manager by searching ComfyUI CV. Needs opencv-contrib-python-headless~=5.0.0.93, Python 3.12+ and a V3-API ComfyUI. To actually write the .csv you'll also want Basic Data Handling installed - it's one of the three helper packs the example workflows depend on, along with ComfyUI-Inspire-Pack and ComfyUI-Custom-Scripts.

Traps

  • decimals = 4 is a lie about precision. For a report it's exactly right. For anything you intend to re-read and compute on, use -1 or accept that your round trip has been quantised.
  • Nothing here normalises anything. No unit conversion, no transpose, no column selection. A 3×3 matrix prints as three rows of three numbers in whatever order the array was stored - check CV Inspect Data if you're unsure which axis is which.
  • JSON keeps structure, the table formats flatten. If a downstream node needs the nesting, don't pick CSV and hope.
  • Newline-separated means your header can't contain a comma unless you're deliberately building extra columns. The tooltip says comma-separated and means it.
Categoryimage/CV/low-level

Inputs (5)

NameTypeDefaultDescription
nparrayNPARRAYArray to format. 1-D becomes one row, 2-D one row per row; anything higher is flattened to (-1, last axis) for the table formats and kept fully nested for JSON.
formatCOMBOCSV/TSV/plain emit one line per row with the chosen separator - 'Parse Matrix' reads all three back. JSON emits a nested list, which core 'Extract Text from JSON' and the chart nodes can consume.
decimalsINT4-1–17Digits after the decimal point for float arrays. -1 prints full repeatable precision (17 digits) - use it when the text is a round trip, not a report. Integer arrays always print exactly.
headeroptSTRINGOptional column names, comma-separated, written as the first line (table formats only). Keep it ASCII - workflow JSON is read with the Windows codepage.
max_elementsoptINT1000001–10000000Safety cap: stop after this many values and report it on 'truncated'. Formatting a whole image would produce a multi-megabyte string that the UI has to carry.

Outputs (3)

NameTypeDescription
textSTRINGThe formatted table. Newline-separated; no trailing newline, so 'Parse Matrix' reads it back unchanged.
rowsINTNumber of data rows written (excluding the header).
truncatedBOOLEANTrue when 'max_elements' cut the table short - the text is then incomplete and must not be round-tripped.