Source Script Node (Table)

Experimental

This node allows you to customize data extraction and manipulation then return data in tabular form to the following node.

Example: Read tabular data from a file (e.g., CSV) and return it as a table or structured data.

var tableContent = FileUtil.readFile("d:\\tmp\\file.csv");
// Perform any required operations on the table
return tableContent;

Example: Retrieve data from API and return in Tabular format

// Retrieve exchange rates from the API
var request = HttpUtil.get("https://boi.org.il/PublicApi/GetExchangeRates");
var jsonContent = JsonUtil.parse(request.asString().getBody());
var exchanges = jsonContent.exchangeRates;

// Create a table to store the data
var table = SuiteTable.create("MyTable");
table.addStringColumn("key");
table.addDoubleColumn("rate");
table.addStringColumn("lastUpdate");

// Populate the table with data from the API
for (var i = 0; i < exchanges.size(); i++) {
    var item = exchanges[i];
    var key = item.key.asText();
    var rate = item.currentExchangeRate.asDouble();
    var date = item.lastUpdate.asText();
    
    var row = {
        "key": key,
        "rate": rate,
        "lastUpdate": date
    };
    

    table.addRow(row);
}

// Filter table with some type of selection example:
var selection = table.stringColumn("key").isEqualTo("USD");
var filteredTable = table.where(selection);

// Return the filtered table
return filteredTable;

Last updated