Icon

5. Empty Table Switch

<p><strong>Empty Table Switch</strong></p><p>This workflow implements another example of a CASE Switch and demonstrates the use of the <em>Empty Table Switch</em> node.</p><p>First, we access the <em>cars-85.csv</em> dataset. With the two <em>Value Selection Widget</em> nodes, we select a car manufacturer and a type of wheel drive. We filter the dataset to the selected car manufacturer and then follow three different workflow branches depending on the selected type of wheel drive:</p><ul><li><p>Case 1 (port 0): fwd</p></li><li><p>Case 2 (port 1): rwd</p></li><li><p>Case 3 (port 2): 4wd</p></li></ul><p>In each branch, we filter the dataset to the selected wheel drive and send the resulting data table back to a <em>CASE Switch End</em> node. Finally, we aggregate the data using a <em>GroupBy</em> node.</p><p><strong><em>Note.</em></strong> Depending on the selected car manufacturer and type of wheel drive, the second <em>Row Filter</em> might produce an empty data table. Empty tables can still be processed by nodes further down in the workflow, however, some nodes require a non-empty data input which then would lead to node failure. To prevent this from happening, we add an <em>Empty Table Switch</em> node to each branch. This node has two output ports: the top port is active when the output table is not empty, the second port is active when an empty table is created.</p>
Annotations and comments
  • Workflow: Empty Table Switch This workflow implements another example of a CASE Switch and demonstrates the use of the Empty Table Switch node. First, we access the cars-85.csv dataset. With the two Value Selection Widget nodes, we select a car manufacturer and a type of wheel drive. We filter the dataset to the selected car manufacturer and then follow three different workflow branches depending on the selected type of wheel drive: Case 1 (port 0): fwd Case 2 (port 1): rwd Case 3 (port 2): 4wd In each branch, we filter the dataset to the selected wheel drive and send the resulting data table back to a CASE Switch End node. Finally, we aggregate the data using a GroupBy node. Note. Depending on the selected car manufacturer and type of wheel drive, the second Row Filter might produce an empty data table. Empty tables can still be processed by nodes further down in the workflow, however, some nodes require a non-empty data input which then would lead to node failure. To prevent this from happening, we add an Empty Table Switch node to each branch. This node has two output ports: the top port is active when the output table is not empty, the second port is active when an empty table is created.
  • Reading data
  • Creating flow variable To control CASE Switch
  • Aggregating data: Count by fuel type
  • Case 1 (port 0): Wheel drive = fwd
  • Case 2 (port 1): Wheel drive = rwd
  • Creating flow variable To filter dataset
  • Case 3 (port 2): Wheel drive = 4wd
  • Active port derived from port variable (selected wheel drive)
  • Count by fuel-type
  • Filter data to selected manufacturer
  • Filter to fwd
  • Filter to rwd
  • Filter to 4wd
  • Select wheel drive; Default: fwd
  • Select car manufacturer; Default: alfa-romeo
  • Create port variable based on selected wheel drive value

Nodes

Extensions

Links