B2Win Suite Documentation (Under Construction)
5.4
5.4
  • B2Win Suite Documentation
  • Scripting
    • B2Win Suite Scripting Overview
    • Scripting in B2Data
      • Custom Script Nodes
        • Custom Script
        • Source Script Node (File)
        • Source Script Node (Table)
        • Source Script Node (Object)
        • If-Else Condition
        • Condition Node
      • In DataPrep
      • Properties
      • Workflow Applications
        • Workflow #1
        • Workflow #2
    • Getting Started
    • Language Basics
    • Types & Objects
      • Primitives
      • Objects
        • Instant
        • LocalDateTime
        • LocalDate
        • LocalTime
        • JsonNode
        • ObjectNode
        • File
        • SuiteTable
        • Duration
      • Arrays & Maps
      • Row, Column, StringColumn
    • Utilities
      • Date & Time
        • InstantUtil
        • GeneralDateUtil
        • LocalDateTimeUtil
        • LocalDateUtil
        • LocalTimeUtil
        • Formatting
        • Timezones
      • Math
      • StrictMath
      • NumericUtil
      • DbUtil
      • DbExecutor
      • StateUtil
      • FileUtil
      • JsonUtil
      • HttpUtil
      • NodeInputReader
      • RandomUtil
      • HashingUtil
      • CompressionUtil
      • Logging
    • Properties
    • Context and System
      • Context
      • System
    • Configurations
      • Workflow Configuration
    • Tutorial
    • Feedback
  • B2Data
    • Workflow Settings
      • General Settings
      • Global/All Properties
      • Execution Configuration
        • General
        • Runtime
        • Compiler
        • Storage
        • Clean Up
      • Permissions
    • Nodes
      • Scheduler
    • Services Configuration
      • Power BI
Powered by GitBook
On this page
  • Methods
  • Examples
  1. Scripting
  2. Utilities

NodeInputReader

The NodeInputReader class provides methods to retrieve node input in various formats, such as Files, Tables, and Data objects.

Methods

inputAsFile(): File

Gets the node input as a File object.

var fileInput = NodeInputReader.inputAsFile();
// Use the 'fileInput' File object in your code

inputAsDataFrame(page: Integer, limit: Integer): Table

Gets the node input as a Table object that can be queried and read. This method is useful for working with data in a tabular format.

Parameters

  • page (Integer): The page number for data pagination.

  • limit (Integer): The maximum number of rows to retrieve.

var page = 1;
var limit = 10;
var tableInput = NodeInputReader.inputAsDataFrame(page, limit);
// Use the 'tableInput' Table object in your code

inputAsDataObject(): JsonNode

Gets the node input as a Data object that can be read.

var dataObject = NodeInputReader.inputAsDataObject();
// Use the 'dataObject' JsonNode in your code

inputAsFileIndex(index: Integer): File

Gets the node input as a File object by an index. This is used when there are multiple inputs.

Parameters

  • index (Integer): The index of the input.

var inputIndex = 0;
var fileInput = NodeInputReader.inputAsFileIndex(inputIndex);
// Use the 'fileInput' File object in your code

inputAsDataFrameIndex(index: Integer, page: Integer, limit: Integer): Table

Gets the node input as a Table object by an index and allows for pagination when working with large datasets. This is used when there are multiple inputs.

Parameters

  • index (Integer): The index of the input.

  • page (Integer): The page number for data pagination.

  • limit (Integer): The maximum number of rows to retrieve.

var inputIndex = 0;
var page = 1;
var limit = 10;
var tableInput = NodeInputReader.inputAsDataFrameIndex(inputIndex, page, limit);
// Use the 'tableInput' Table object in your code

inputAsDataFrameTotalRows(): Integer

Gets the number of parts the DataFrame has.

var totalRows = NodeInputReader.inputAsDataFrameTotalRows();
// Use the 'totalRows' Integer in your code

inputAsDataFrameByIndexTotalRows(index: Integer): Integer

Gets the number of parts the DataFrame has by DataFrame index.

Parameters

  • index (Integer): The index of the DataFrame.

var inputIndex = 0;
var partsCount = NodeInputReader.inputAsDataFrameByIndexTotalRows(inputIndex);
// Use the 'partsCount' Integer in your code 

inputAsDataFrame(): Table (Deprecated)

Gets the table object. This method is deprecated and should not be used. Instead, use inputAsDataFrameIndex() with page and limit for more controlled data retrieval.

Examples

Example: Get Columns Max Value

Description: This script retrieves the maximum value from the 6th column of an input table.

Use Case: Useful when you need to find the highest value in a specific column of a dataset.

// Get a copy of the table reference from the previous node
var table = NodeInputReader.inputAsDataFrame(1, 10);

// Get a new table sorted by the 'name' column descendant
table = table.sortDescendingOn("name")

// Get the values of the 'name' column from the first row (Index 0)
var maxValue = table.stringColumn("name").get(0);

Example: New Table Filtered

Description: This script filters a table based on a condition, creating a new table with filtered data.

Use Case: Ideal for data preprocessing and filtering based on specific criteria.

// Get a copy of the table reference from the previous node
var table = NodeInputReader.inputAsDataFrame()

// Gets the "gender" column as String
var stringColumn = table.stringColumn("gender");

//Return a new table with only value: female filtered
return table.where(stringColumn.endsWith("female"));
PreviousHttpUtilNextRandomUtil

Last updated 1 year ago