Working with Datasets

You can use datasets to simplify the structure of your graph and to ease the management of complex lists.

Four operators let you work with datasets: Data Set, Data Set From Table, Data Sets To Table, and Explode Data Set.

Important: Some visuals in this page are based on the user interface in an earlier release, but the concepts described are still valid.

This task shows you how to:

Context: A dataset is an informational object that stores a collection of attributes. An attribute combines a name and a value.

The values of the attributes in a dataset can be of any type: numbers, geometries, images, colors, etc. The values can also be other datasets.

By default, the values always contain unique elements. However, they can also include lists or more complex structures by modifying the dimension of the associated connectors.

Reduce the Number of Dataflows

A dataset lets you group attributes in one object and then use it through a single dataflow.

  1. In the editor, insert a Data Set operator.
  2. Connect attributes to the attr inputs.

    Tip: You can rename the attr inputs.

    The output of the Dataset node groups the input attributes in a single object.

  3. Insert the Explode Data Set operator, and then connect the Dataset node to Explode Data Set.
    The attributes are processed through one single dataflow.
  4. In Explode Data Set, click Update Outputs to retrieve the attributes as outputs.

Result:

Enrich an Existing Geometry

A dataset lets you extend an existing geometry by giving it new attributes, including geometries.

  1. In the editor, insert a Data Set operator.
  2. Connect the existing geometry to the extend input.
  3. Connect the attributes to add to the attr inputs.

    Tip: You can rename the attr inputs.

    The output of the Dataset node groups the existing geometry and its new attributes.
  4. Insert the Explode Data Set operator, and then connect the Dataset node to Explode Data Set.
  5. In Explode Data Set, click Update Outputs to retrieve the attributes as outputs.

Result: In this example, the following attributes are added to the definition of a sphere: center, volume, and bounding box.

Convert a CSV File

You can create a dataset using a CSV file as input.

  1. In the editor, insert a Read Data From Sheet operator, and specify a CSV file.

    For more information, see Read Data From Sheet.

  2. Connect Read Data From Sheet to a Data Set From Table operator.
    The structure of the table in the CSV file is processed. Each row generates a dataset and the attributes correspond to the content of the columns.
  3. Insert the Explode Data Set operator, and then connect Data Set From Table to Explode Data Set.
  4. In Explode Data Set, click Update Outputs to retrieve the attributes as outputs.
  5. Connect each output attribute to a Watch operation.

    This allows you to display the content of each column.

Result: In this example, the CSV file has 4 columns. Each column corresponds to an attribute: Country, Ratio, Number, and Revenue.

Tip: Use Read Data To Sheet to create a CSV file based on the content of a dataset.

Simplify User Operators

You can use a dataset to reduce the number of connections between your user operators.

You can either:

  • Group outputs to create specific datasets
  • Group all the outputs in a single dataset

  1. Connect a Data Set operator to all the outputs of a first user operator.

    Note: If the outputs don't have the same number of items or the same list structure, you can change their dimensions. Setting a dimension of -1 on all inputs of the dataset allows you to create only one dataset which contains the whole structure.

  2. Connect the output of the DataSet node to an Explode Data Set operation.
  3. In Explode Data Set, click Update Outputs to retrieve the attributes of the first user operator.

Result: In your graph, a single dataflow allows to retrieve the necessary outputs to connect to a second user operator.

For example:

Ultimately, you can embed Data Set nodes in your user operators to have only one input and one output to connect: