Node File Reader to read multiple files

Hello all,

I am a young developer and new to KNIME. I have spent a good amount of time sifting through examples and haven’t found one that expresses the capabilities for the node I’m looking for. I am not sure if there is a configuration for File reader.

Is there a input start node that will read multiple files from “List of Files” from a folder? I am trying to collect information from multiple text file and have them organized in a table to get catalog with inventory. Should design a loop function instead? How could I do that?

Look one more time, please.
https://www.knime.com/nodeguide/control-structures/loops/example-for-reading-a-list-of-files

2 Likes

Hello @michaellis,

Yes, you need to implement a loop to iterate though the file list. Please take a look at this sample in the sample server that demonstrates this. The meta node step is not needed in your case but it is so the sample can run on your environment.

https://www.knime.com/nodeguide/control-structures/loops/example-for-reading-a-list-of-files

1 Like

Thank you, I appreciate the directions.

If you want the whole of each file in a single cell, take a look in the Vernalis community plugin too
Steve

@cpadilla @izaychik63

Is there a guide to the Java edit variable? I’m not familiar with Java Script. The example is not clear as to how the Java Edit Variable will direct which file for the File Reader Node to open and read in the loop.

I originally thought that you would have the Java edit variable before the start of the loop, directing each file to be read, manipulated and then close the loop and compile a cataloge a the end of the workflow.

Thank you for your help

Hi @michaellis,

This is to have unique RowIDs for this example.

The Java Edit Variable node script is setting the user generated variable out_rowpre to “File-x-Row” where x is the current loop iteration (0-6). This java variable is assigned to the Flow Variable row-prefix that is set on the File Reader node under the Flow Variables tab (rowPerfix = row-prefix).

image

Then, if you see the Loop End node, the Row key policy is set to “Leave row IDs unmodified.” When using this setting in the loop, you need to make sure you do not have any duplicate RowIDs in between different iterations.

image

I hope this makes sense.

cpadilla

@cpadilla Yes that makes sense! Thanks

However the next problem I am running into is my File reader is receiving an error that the input does not exist.Its as if the File Reader node is reciving the command to read the file in the Row from the List Files

File%20ListFile%20List2

![Node_File_Reader|690x206]

Try: Right click on the Java Edit Variable node, click reset and execute again. Then open the File Reader node and you should see the contents of the file.

To All:

There seems to still be an input problem with File Reader. Let me explain better what I am trying to do.

I have a list of notepad text files contained in folder. I am trying to open the at folder to a list to then take each row in that list’s URL and mine the information from each notepad file to a final table containing all the information from the notepad files from that folder into one list.

Using the pre made example, it states to use a “table row to variable start loop” to create a loop, opening each file, mining the data from notepad files using “row filters” and them compiling it in a single table.

My troubles are :

  1. I do not fully understand how the variable will tell the “file reader” to read each file from the “list of file node” and the push that information through the work flow.

  2. how do I make sure that each file’s will be placed only once the table? The loop seems to repeat one files over and over in the table.

  3. how do I add a new column to the table to create a label catalog to indicate which file the data came from? I was trying to use another row filter and then unpivoting to label each row.

Thank you so much for your help and patience. I really enjoy using Knime.