How to read all files in a folder with a loop


#1

I am trying to find an elegant way to loop over a series of files contained in a folder. I tried implementing community examples (https://www.knime.com/nodeguide/control-structures/loops/example-for-reading-a-list-of-files) and a few variants, but I keep getting an error that says: Errors loading flow variables into node : Coding issue: Cannot create URL of data file from \my_folder.

I created a flow variable in the List Files Node. My understanding is that this will create a list My_list, pass it onto the file reader (which I set to use My_list as the variable). The node throws an error telling me that the “DataUrl” parameter is controlled by a variable. Isn’t this exactly what I am trying to/supposed to do?

In the file location browser it says that the input location is a directory, not the list of files I want to loop over. How can i fix this?

47%20AM

03%20AM


#2

Hi Emilio,

The Table Row To Variable Loop Start node will automatically create a variable out of the list passed on by the List Files node, so no need to create the My_list variable. Simply select the folder in the List Files node that you want to scan, add any filters and your loop will go through all of those outputs in the File Reader. Just choose for example the URL column in the File Reader node as the location of the files you want to read.

Let me know if this helps!

Cheers,
Medzi