Icon

08. Workflow Control - solution

Workflow Control - Solution

Solution to exercise 11 for the KNIME Analytics Platform for Data Wranglers course
- Write subsets of a file using a loop
- Read and concatenate many files using a loop
- Activate a workflow branch based on a user selection

Annotations and comments
  • Activity I: Write Multiple Excel Sheets into an Excel File Goal: Build a loop that will create an Excel file with separate Excel sheets for the records of different products. - Read the table CurrentDetailData.table (Table Reader node) - Start a loop that handles the records for the different products in separate iterations (Group Loop Start node) - For each product write one Excel sheet into a single Excel file (Excel Writer node) Tip: Control the flow variable sheet_name in the Flow Variable tab by using a flow variable created by the Group Loop Start node - Close and execute the loop (Variable Loop End node)
  • Activity II: Concatenate Multiple Excel Sheets Goal: Create a loop that reads and concatenates all the sheets in an Excel file. - Create a table that contains all sheet names (Read Excel Sheet Names node) - Start a loop that iterates over the sheet names (Table Row to Variable Loop Start node) - Read the Excel sheet with the sheet name in the current iteration (Excel Reader node) %%00009Tip: Use the flow variable created by the Table Row to Variable Loop node to control the setting sheet_name in the Flow Variable tab - Close the loop and concatenate the tables from the different iterations (Loop End node)
  • Activity III: CASE Switch Extend the workflow below with a switch that only creates one type of visualization. - Create a Single Selection Configuration node with the possible values "scatter" and "bar" - Drag the CASE Switch Start node, and Click on the three dots on bottom left corner of the node to add input port as Table, use this node to activate the top/middle branch depending on the selection scatter/bar (Use the "...(index)" flow variable to define the active port) - Combine the outputs of the two branches with the CASE Switch End node, you can add the output port as Table to this node by clicking on the three dots and then adding output port.
  • Combine paths into one
  • Read one sheet per interation
  • Write records of current iteration into an Excel Sheet
  • Records of one group per iteration
  • Combine all sheets into single table
  • Create table with all sheet names
  • Select bar or scatter
  • Read entire table
  • Read CurrentDetailData
  • Loop over all sheet names
  • Collect variables and end loop

Nodes

Extensions

Links