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

Activity I: Write Multiple Excel Sheets into an Excel FileGoal: 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 Startnode - Close and execute the loop (Variable Loop End node) Activity II: Concatenate Multiple Excel SheetsGoal: 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) Tip: Use the flow variable created by the Table Row to Variable Loop node to control the setting sheet_name in the FlowVariable 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, usethis node to activate the top/middle branch depending on the selection scatter/bar (Use the "...(index)" flow variable to define theactive 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 byclicking on the three dots and then adding output port. Records of onegroup per iterationSelect baror scatterCollect variablesand end loopWrite recordsof current iterationinto an Excel SheetCreate table withall sheet namesRead one sheet perinterationRead entire tableLoop overall sheet namesRead CurrentDetailDataCombine all sheetsinto single tableCombine pathsinto one Image To Table Image To Table Table To Image Scatter Plot Bar Chart Group Loop Start Single SelectionConfiguration Variable Loop End Excel Writer Read ExcelSheet Names Excel Reader Table Reader Table Row ToVariable Loop Start Table Reader Loop End CASE Switch Start CASE Switch End Activity I: Write Multiple Excel Sheets into an Excel FileGoal: 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 Startnode - Close and execute the loop (Variable Loop End node) Activity II: Concatenate Multiple Excel SheetsGoal: 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) Tip: Use the flow variable created by the Table Row to Variable Loop node to control the setting sheet_name in the FlowVariable 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, usethis node to activate the top/middle branch depending on the selection scatter/bar (Use the "...(index)" flow variable to define theactive 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 byclicking on the three dots and then adding output port. Records of onegroup per iterationSelect baror scatterCollect variablesand end loopWrite recordsof current iterationinto an Excel SheetCreate table withall sheet namesRead one sheet perinterationRead entire tableLoop overall sheet namesRead CurrentDetailDataCombine all sheetsinto single tableCombine pathsinto one Image To Table Image To Table Table To Image Scatter Plot Bar Chart Group Loop Start Single SelectionConfiguration Variable Loop End Excel Writer Read ExcelSheet Names Excel Reader Table Reader Table Row ToVariable Loop Start Table Reader Loop End CASE Switch Start CASE Switch End

Nodes

Extensions

Links