Workflow control and Loops

I am 5-day trained in KNIME by National Government Agency and doing my first workflow. The idea is to create a pivot after a group with some exceptions and conditions on a dataset (available in MS Excel) and was able to get the desired result. However, I am having the following issues

  1. The workflow works as expected on single file. But I will get multiple such files (probably in 100’s). So I have used List Files/Folders - Table Row to Variable Loop Start - Excel Reader - Variable Loop End. As the output is to be written to another MS Excel File, only the last iteration file is getting generated. How to generate MS Excel File (output) for each iteration?

  2. In Create File Name node, Output flow variable is available as String, where as in Excel Writer node, file_selection is Path variable. So I am using String to Path node in between. Is this a known issue?

  3. I wanted to work on File paths, so I have tried to use URL to File Path node, but I am getting the following error: No column in spec compatible to “StringValue” or “URIDataValue”.

  4. In the data set, column FundSource will have multiple values. I have used Row Filter and worked on workflow to generate the output in excel. How can I make it dynamic (as I will not know the different FundSource available, so cannot use Row Filter also). How to make a Loop inside a Workflow Loop.

In all, the output of the workflow should be… for each data set available (MS Excel Files) and for each FundSource in that data set one Excel file output should be generated.

I am attaching the WorkFlow and the sample input files (for testing I am using 2 files City1 and City2 for List Files node).

Thanks

Block_Account.knwf (71.3 KB)

City1.xls (283 KB) City1.xls (283 KB)

~Oneflydown

@pdarlyscr welcome to the KNIME forum.

For starters I would like to pint you to a few resources you might want to combine.

Loops, Excel File handling and File Handling Guide

For File handling you have URLs, URI, File Paths and Path variables. That can sound challenging at first but once you start combining you will have all the options you need. Most new file handling nodes will use Path variables and you can create them by combining strings. One thing to note about Path variables is that you will auswäscht have to make sure you see what ‚system‘ of file handling you usw. KNIME-protocol, relative paths, absolute paths on your file system (or even a remote server). The mentioned file handling guide is extensive but I would recommend reading it to understand how KNIME does handle files and paths.

I might have a look at your example but you might want to describe what you want to do.

Thank you @mlauber71 for the quick response.

I will go through the resources you have provided. Regarding the workflow I will keep it simple.

I will have data like this in an MS Excel File:

Col1 Col2 Col3
A
A
A
B
B
D

Individual excel files need to be generated for rows with A, B, D… Here, the values of Col3 are variable, i.e some source files might have only one value and some might have n values. And also, the number of source files is variable. So for each source file, I want to generate an excel file for each Col3 value.

Thanks
~Oneflydown

OK this sound different from the workflow you posted before. My advice would be to generate an example that represents you specific challenge in detail but also isolated so we can focus on solving that specific problem you might get stuck with.

In this case I would recommend to take a look at this example. You combine Scan files, Reading of Excel Sheets and then in your case you would make a Group by on the “Col3” node for each file/sheet and then export that to (new) Excel files. You just should make sure your ‘wiring’ of the loops would be correct and you would encapsulate everything that should happen within the loop and you would make sure that what you want gets done in a systematic way.

I do not understand everything in the workflow but in order for it to work you might have to use a different ‘wiring’ (no guarantee that this fixes the whole workflow).

You already have discovered the most powerful automation node in the KNIME arsenal :slight_smile: The Tabel Row to variable Loop start where you can iterate about everything you can imagine in a systematic and flexible way. You might have to make some preparations (group by nodes) and use variable nodes to create new paths and file names in a dynamic way. But with some planning this is easier than it look at the first glance.

1 Like

Yes I figured out that from your earlier post @mlauber71 and it is an excellent compilation of resources.

As you have mentioned, I have missed the loop between Excel Writer and Variable Loop End nodes. Now the workflow is perfect. For the inner iterations (different Col3 values), I am using Group Loop Start, and for each Group Item, I am generating dynamic file name and writing the content to Excel Files.

Thanks
~Oneflydown

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.