automate reading csv files

The "csv file reader" node reads a file that is specified during the configuration of the node.

I want to read a list of files, then loop over them.  To do this what I need is a csv reader that takes the file name as an input argument, or a list of filenames like that produced by the "List Files" node, and then can read and process each of them in a loop.

Is there a way to accomplish this? It seems like this should be an automatable task, but the nodes don't appear to support it.

to use loops and flow variables you have to access knime in the expert mode.

therefore navigate to your knime folder and add the following line in your knime.ini file:

-Dknime.expert.mode=true

you'll see a new node category after knime restarted.

I'm not quite sure , but I think there is an example for reading several files in the knime labs or the knime example workflows. Does anybody know?

I was trying the same work. Executing a loop on csv file names but I cannot find a way, even if  add the line on my knime.ini file.

No new category appeared.

Hi All,

I think what you are trying to do seems reasonable enough.  I have assembled a short test workflow (Knime 2.4.0 - see attached file including dummy data) to demonstrate the following:

List Files ->(data out)  ##Selects all of the .xls files in a particular folder by file extension##

(data in)-> TableRow to Variable Loop Start ->(flow variable out)  ##Starts the loop##

(flow variable in)-> XLS Reader ->(data out)  ##Set the Location field to use the Location variable coming in##

(data in)-> Java Snippet ->(data out)  ##Example of doing something with the file - in this case counts the rows##

(data in)-> Column Filter ->(data out)  ##Discards everything except row count column##

(data in)-> TableRow to Variable -> (flow variable out)  ##Passes the first row out as variable (also keeps the original variables that were being passed along##

(flow variable in)-> Variable to TableRow ->(data out)  ##Selects and passes out just the location and row count info##

(data in)-> Loop End ->(data out)  ##Ends the loop and concatenates each row corresponding to each input xls file##

 

I believe 2.4.0 now comes with the .ini defaulting to expert mode, so you should see the flow control nodes, and the show/hide flow variable ports options when you right-click nodes.

Obviously, the same approach can be used for any file type.  Hope this helps!

 

Kind regards

James

Nice work, thank you.

That'll help.

You also have the Variable Based File Reader node (in Flow Control/Variables) which you may find of use too.

Simon.

Hi!

 

I'm trying to read several cvs files ... but I can't!! It always read the same file, the number of times it reads is correct.

The Jame's example mark an error :(

Please help me. Attached the file

Cheers,

Silvia

 

Hi,

I am new to KNIME, I was using WEKA before. I have a CSV training file with class value in it, can I use KNIME for classification of my training and testing csv files?. Please let me know. Thank you in advance.

 

Best Regards,

Satish

Similar problem solved:
https://tech.knime.org/forum/knime-textprocessing/loading-multiple-csv-files-and-text-process
Piotr