How to read files in a loop and append a column that specifies the file

I have a list of files (file1.tsv, file2.tsv, file3,tsv, etc) with the same format.

For example, for the first file I would have:

City         Counts   TPM
Hong Kong    124      225
Barcelona    3465     234
New York     256      4645

Right now I’m doing the reading with a loop and a file reader.

However, I would like to, at the same time I read the files, append another column that specifies from which file the readings are coming from:

City         Counts   TPM     File
Hong Kong    124      225     File 1
Barcelona    3465     234     File 1
New York     256      4645    File 1
Hong Kong    143      275     File 2

Hi @RoyBatty296

Under the advanced tab, enable the Path Column.

If you only want the file name, add a Column Expression with getFileName(column("Path"))

Hope this helps!


Thanks @ArjenEX , but it’s a file reader, not a csv reader. I couldn’t find that option in the node.

Hi @RoyBatty296

It’s definitely there.

1 Like

Thx @ArjenEX I had an older version of KNIME

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