Transform the variable "Serving Size" into a usable format

Hi I’m new to this software could anyone help me out please?

Currently, the variable “Serving Size” is in the STRING format. Are there any ways to transform the data into the INTEGER format?

Will be great if I can separate the data into two columns, ‘fl oz cup’ and ‘g’ respectively.

Thanks in advance!

1 Like

Hi @jiaying01 , separating the columns can be easily done with Cell Splitter Node.

But I wouldn’t recommend it since you will lose the details that the column needs for it to make any sense, once you remove the non-numeric characters like oz or fl oz. (Unless all values in the column are standardized to one measurement e.g. converting to grams.)

1 Like

Hi @badger101 Is there a node in KNIME that allows me to do the standardization?

Yes, you can use the Math Formula to convert, say, oz to gram by multiplying the values with 28.3495.

Obviously, you’ll have to separate the rows of fl oz from the rows of oz, or else they will be subjected to the same calculation which is not what you want.

1 Like

Really sorry for bothering you… But how do I separate the rows of fl oz from the rows of oz?

If you only have two measuring units (oz and fl oz), then you can use the Row Splitter node.

1 Like

I have three.

As I just started learning about KNIME, I have not been introduced to the Row Splitter Node

Can you check with the whole dataset to confirm that ‘fl oz’ rows are the only ones that don’t have pre-conversion to grams?

Yes that is right. No conversions.
*Just saw that the row splitter node requires some user-defined rules and I have no knowledge in programming (except simple python programming)

Okay, I’ll go and work out a dummy workflow and will share it here.

Convert to Grams.knwf (49.4 KB)

Okay, try this template workflow. Let me know if there’s issues pending.

2 Likes

Thank you so much for you help. It will take me some time to fully understand the workflow as it is really complicated to me. I will let you know when I encounter more problems. Once again, thank you and sorry for taking up your time.

Sure thing! Since you’re new to the software, it’s understandable that you’ll perceive it as complicated. Once you’re familiar with configurations of the nodes, you’ll find that the workflow is as straightforward as it can be.

6 Likes

hey @badger101, I’m new to KNIME and I’m also stuck on a very similar dataset, I’ve went through your conversion template but I still don’t understand it. Can you help me out?

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