File name including iteration

Hello all. Normally, I can figure out issues I am having by reading around online, but I am stumped so I think I need to ask the experts. I have a loop set up where I cut a spreadsheet into manageable chunks (because our system gives up over a certain number of rows) and writes them into .csv files. That saves us a lot of manual cutting and pasting.

What I would like to is to be able to have file names of “String”+$${iCurrentIteration}$$, so I can get a list of .csv files which appear as below:

MyFile_Part0.csv
MyFile_Part1.csv
MyFile_Part2.csv

Currently, I have the create file name node set up to have base file name using the CurrentIteration variable, but I can’t figure out how to get the string in front of it.

Hello @JWebb,

welcome to KNIME Community!

You can use join() function from String Manipulation (Variable) to create flow variable with desired file name.

join(MyFile,"_Part",$${iCurrentIteration}$$)

You don’t need Create File Name if I got you right. Also if “MyFile” is name of file you are reading you can automate this by creating a flow variable In Excel Reader holding file name. See here for more: https://docs.knime.com/latest/analytics_platform_flow_control_guide/index.html#creating-local-flow-variables

Br,
Ivan

Hello Ivan, thanks for the suggestion. That looks far more promising! I’m a bit stuck on applying that formula though. I have not come across the error before as it’s the first time I am using this node, so apologies if this is a really novice mistake! I even tried cutting it down to a really simple string so I thought just have “Part0.csv” etc., but to no avail.

KnimeError

It would be helpful if you shared the workflow, or at least showed the configuration of the node.

The error message references line 64. What do you have on line 64?

Fresh day, fresh brain and I figured it out. It’s because the current iteration is an integer, not a string. That was all :slight_smile: All fixed and it works with a test file! Thanks for your help everyone.

2 Likes

Hello @JWebb,

glad you figured it out on your own :slight_smile:

You can mark specific reply as solution (button is hidden behind 3 dots in right bottom corner of every reply). Helps us keep forum clean.

Also make sure to explore KNIME Hub and possibly contribute with your solutions :wink:

Br,
Ivan

Thanks Ivan. I have had a look and will assist where I can, but I’ve not been using Knime for that long!

1 Like

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