Add column with fixed value from title of Excel file

Hi all,

I have a question. I am looking for the possibility to add a column with a fixed value to my excel file. However this fixed value should come from the title of the excel file, for example: the file is called 20200605_921_TK.xlsx. I would like to add a column with the fixed value of 20200605, a column with 921 and a column with TK.
Can anyone help me out on this, if this is possible?

Thanks in advance!

Sander

Welcome to KNIME forum.
First read your file with Excel Reader. On Excel reader configuration Flow Variable tab find FILE CHOOSER group and inside it pick path_or_url variable. In the empty box input desirable name, say MyExcelPath.
Then using Variable Expression node extract parts of the MyExcelPath in 3 different variables and use Column Expression to add them to the original file.
Write file with overwrite option with Write Excel Writer node.

1 Like

The process is actually very straight forward. What you want to do is create a variable from the file name you read. Likely you will strip off the path of that variable to be left with just the filename. Then use a cell splitter to break the filename down by the underscore.

I attached a simple example using an exceSample 1.knwf (21.4 KB) Address Verification Codes.xlsx (16.2 KB) l file. But I used a space as the divider instead of an underscore. But I think you will get the concept.

2 Likes

You could look at this example:

@gregmurphy welcome to the KNIME forum :slight_smile:

1 Like

Hello @gregmurphy,

check out here how to share your solutions with Community (and welcome to it!):

Br,
Ivan

1 Like

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