Adding column to the data set with a constant value (indicated in the source file)

HI ,

My dataset (large multiple text files) after CSV Reader step looks like that:

image

I am trying to add a column (2 actually) to the above set.
The column name and value are highlighted above so 1st column needs to be called FundID with value which is currently blacked out and 2nd column is FileFormat with corresponding value.

How to go about it , please? Potentially setting variable for each element?

Seems like ‘constant column value’ works just fine for the above.

However as I have a multiple file , I suppose , i would need to add constant column value node to each text file before combining them all - can someone confirm, please?

That seems like a lot of nodes if I have 20 text files.

Hello @Pawel40Adi ,

here is a possible solution: tell me if it works.

In case of multiple files, adding two columns for each file and concatenating would be easier, especially if each file will have different values inside the two columns. If the values are always constant, you can also concatenate and then create the two columns.

RB

HI @lelloba , thanks for this but I dont think ‘column expression’ exist anymore as a node - there is no clear information what it has been replaced with.

I tried the following solution but it takes an enormous amount of time to convert the data (not surprising as my data has over 2 million rows):

image

My heart missed a beat when you said “I dont think ‘column expression’ exist anymore as a node”. :joy: I use it extensively and cannot live without it :joy: Column Expressions – KNIME Hub

Select just the column you need to transpose, otherwise it will take too much time!

However, was my solution working for you? Why do you need to transpose the dataset?

RB

1 Like

LOL…

Apologies , it wasn’t my intention to cause you a health issue…

I must be doing something wrong then:

image

To answer your question I need to promote my first row of data to column hence my transpose method I tried:

My output after column filtering is this:

Take the link I sent you, drag and drop the yellow icon in KNIME and follow instructions. You may be missing an extention.

immagine

For the promotion, you can try to select Row5, transpose it and use it inside insert column header node.
Otherwise, have a look at this: Column Header <-> First Row Community Component

RB

1 Like

1

Column moving/copying node is not working (either with copy nor with move) - please see below:

image

Moreover, it unexpectedly shuts down my KNIME which suggest some deeper issue.

All of my values in first row are string so that should not be an issue.

2
Can you please elaborate on 1st solution - selecting row5 and transpose - not sure how to select row5 and also transpose does not give me any intuitive option I can select:

image

Am i missing something?

Hi @Pawel40Adi ,

have a look again at my previous workflow, I have added the row to header part.

immagine


Select “move” in the option.

RB

HI @lelloba , I think you misunderstood my last post.

I tried both options of ‘Copy or Move row to column header’ node that you provided link to:

  • copy first row
  • move first row

And none of them worked creating an error and even freezing my Knime for some time or closing it.

This node is simply not working for me.

Hope this helps.

I found this topic from 2 years ago that provides a far better solution that anything we discussed above.

Try this:

Happy you have found something better.

RB

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