Skip to content

Add data operations module with CSV import and table manipulation#527

Merged
fdb merged 8 commits intorewrite-in-rustfrom
claude/rust-data-nodes-vegjS
Feb 15, 2026
Merged

Add data operations module with CSV import and table manipulation#527
fdb merged 8 commits intorewrite-in-rustfrom
claude/rust-data-nodes-vegjS

Conversation

@fdb
Copy link
Member

@fdb fdb commented Feb 14, 2026

Summary

This PR introduces a new data operations module (nodebox-ops::data) that provides functions for importing, creating, querying, and filtering tabular data. It adds support for structured data handling throughout the NodeBox system, including new node types and UI components.

Key Changes

New Data Module (crates/nodebox-ops/src/data.rs)

  • DataValue enum: Represents values as either String or Float, matching Java's DataFunctions behavior
  • import_csv(): Parses CSV files with configurable delimiters, quote characters, and number separators (comma vs period). Performs per-column numeric type detection
  • make_table(): Constructs data tables from header names and input lists, padding shorter lists with empty strings
  • lookup(): Retrieves values by key from data rows
  • filter_data(): Filters rows by comparing key values against targets using operators (=, !=, >, >=, <, <=), with automatic numeric/string comparison fallback
  • Comprehensive test coverage for all functions

GUI and Evaluation Updates (crates/nodebox-gui/src/eval.rs)

  • Added DataRow and DataRows variants to NodeOutput enum
  • Implemented display formatting for data rows (sorted key-value pairs)
  • Added helper functions: get_data_rows() and get_as_data_values() for type conversion
  • Updated value_to_output() to handle Value::Map conversion to DataRow
  • Implemented node execution for:
    • data.import_csv: Reads CSV files with proper delimiter/quote handling
    • data.make_table: Builds tables from multiple input lists
    • data.lookup: Retrieves values from data rows
    • data.filter_data: Filters data rows by key-value comparisons

Node Library and UI (crates/nodebox-gui/src/node_library.rs)

  • Added 5 new data node templates: import_text, import_csv, make_table, lookup, filter_data
  • Configured node inputs/outputs with appropriate port types and widgets (file picker, menus, etc.)
  • Added "data" category to node browser filter buttons

Type System Updates

  • Added PortType::Data variant to support data/table ports in the node system
  • Updated port type serialization/deserialization

Dependencies

  • Added csv = "1" crate to nodebox-ops for robust CSV parsing

Implementation Details

  • CSV parsing uses the csv crate for proper handling of quoted fields and various delimiters
  • Numeric type detection is column-wise: a column is numeric only if all non-empty values parse as f64
  • Filter operations support both numeric and string comparisons with intelligent fallback
  • Missing keys in filter operations are treated specially: only != matches rows without the key
  • Data rows are displayed with sorted key-value pairs for consistent UI representation

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo

Add DataValue type and DataRow/DataRows NodeOutput variants to support
structured tabular data. The csv crate handles robust CSV parsing with
configurable delimiters, quote characters, and number separators.
Auto-detects numeric columns. Includes 19 unit tests.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
Kept upstream's new list nodes (pick, cull, take_every, distinct, switch,
combine), network nodes, and section separators. Merged our full data node
port definitions (import_csv with quotes/number_separator, make_table,
lookup, filter_data) on top.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
The Widget::File handler was hardcoded to FileFilter::svg(). Now it
selects filters based on the node prototype: CSV files for import_csv,
text files for import_text, SVG for import_svg, and no filter for
unknown nodes.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
Uses non-interactive TextEdit for the filename (same as string widget),
with a "..." suffix on the right. The entire row is clickable and shows
the same hover effect as other widgets. Clicking anywhere opens the
file picker dialog.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
The data viewer now renders DataRows output as a proper spreadsheet-style
table with separate columns for each CSV field, instead of flat strings.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
Both nodes were stubbed out waiting for map type support. Now that
DataRow/DataRows exist in NodeOutput, replace the stubs with real
implementations and register them in the node library.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
Change lookup's registered output from PortType::String to PortType::Data
(matching the ndbx definition) and add Data → Float/Int/Point compatibility
rules. The runtime already returns NodeOutput::Float for numeric columns;
this fix lets the connection validator accept those wires.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
Data is a dynamic type (lookup can return float, string, color, etc.
depending on the column). Treat it like List — compatible with any
input or output port type, with runtime determining the actual value.

https://claude.ai/code/session_01Ssbet1itX47TACaYWBM1Wo
@fdb fdb merged commit 19f671e into rewrite-in-rust Feb 15, 2026
2 checks passed
@fdb fdb deleted the claude/rust-data-nodes-vegjS branch February 15, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants