1

I am running a knime chunk loop to write always the same procedure in different csv files: enter image description here

The Part with the python script until the csv write is working, when I do it without loop, but somehow he is not writing in the customized folder path, if I have the loop inside.

The target is to write a new csv-file for every loop (the output is a list).

The nodes are: Chunk Loop: Rows per chunk: 51 Create file name:

  1. Options Selected directioy: C:/....
  2. Flow Variables: FileName: currentIteration

CSV Writer: Flow Variables: filename: CurrentIteration

How can I change the folder path of the file? He is always saving it in the default folder

PV8
  • 5,799
  • 7
  • 43
  • 87
  • **Create File Name** has a configuration setting `Output flow variable name`, what is that set to and have you configured **CSV Writer** to match? It looks as if you're creating this variable but not using it to name your CSV file, instead you're just using `currentIteration` from the loop. – nekomatic Oct 29 '19 at 10:12
  • its set blank, do I need to set it to: `currentIteration`? – PV8 Oct 29 '19 at 10:14
  • No, you should enter a new name there and use that name in CSV Writer. (On my KNIME installation it's set to `filePath` by default, perhaps you cleared it by mistake?) – nekomatic Oct 29 '19 at 10:18
  • but will the name change? the output should have different names then – PV8 Oct 29 '19 at 10:24
  • As I understand it you want to save a CSV file with a different name each iteration of the loop? So you configure **Create File Name** with `Selected Directory` = the directory you want, `Base file name` = Use Variable: `currentIteration`, and `Output flow variable name` e.g. `filePath`. Then in **Write CSV File** you set `Output location` = Use Variable: `filePath`. The files will be named `0.csv`, `1.csv`, `2.csv` etc in the folder you selected. – nekomatic Oct 29 '19 at 11:51
  • 1
    If that works I'll make it into an answer... if it's still not clear let me know and I'll try to write an answer with screenshots of the node config so as to explain better. – nekomatic Oct 29 '19 at 11:53
  • cannot do the last step: with file path in the csv write node – PV8 Oct 29 '19 at 13:58
  • 1
    it happens oft with knime, maybe restarting the program would help... –  Oct 30 '19 at 11:11

1 Answers1

1

Here is an example workflow (apologies for the weird blurry Windows 10 screenshots):

KNIME workflow image

Create File Name config:

create file name config

CSV Writer config:

CSV Writer config

You may need to run each node individually in order to create the flow variable before you can select it in the following node.

nekomatic
  • 5,988
  • 1
  • 20
  • 27
  • any idea why I only see: use variable: knime.workspace in the csv writer node? I executed the first node already – PV8 Oct 30 '19 at 06:42
  • 1
    Sorry, I can't think why this wouldn't work. Did you try creating my test workflow from scratch? If you're still stuck I suggest you try posting on the forum at knime.org. – nekomatic Oct 30 '19 at 10:17
  • @nekomatic, is there a way to get Knime to create the folder if it doesn't exist? – Saqib Ali Apr 01 '20 at 00:07