Time standardization

Hello guys,

I am facing with time standardization problem.

I have time in such crazy format as bellow:

min 1 digit d min 1 digit h min 1 digit min min 1 digit s always 3 digits ms

and I would like to get output in minutes or seconds.

Let’s take the first row as an example:

1min 4s 193 ms = 64,193 seconds

or something similar.

can you give me some hints how to do that? Normally it would be very easy, but in my case it is dynamically changed. Sometimes I receive only seconds and ms and sometimes hours, minutes, seconds and ms.

Any idea?

Thank you

Jiri

Hi @sm0lda,

This isn’t the most elegant solution but it should work as you need it too. Because it’s a consistent pattern (from what I can see) I used REGEX to filter and replace, convert to INT then some maths at the end to calculate the seconds total.

Test_Time.knwf (32.3 KB)

P.S I ignore the ms, so in my example 1 min 4 s 193 ms = 64 seconds.

Thanks,

Matt

3 Likes

Just a thought, I suppose, although maybe very rare milliseconds only could happen so this revised workflow just makes sure they don’t get used.

Test_Time.knwf (34.4 KB)

Thanks,

Matt

Brilliant job my friend. Unfortunately I need “ms” as well, but I have already adapted your workflow and now it works with “ms” as well.

Thank you a lot!

2 Likes

Hello!

Here is my solution using Regex Split node to extract all info regardless of time format and new String Manipulation (Multi Column) to leave only numbers:

And here is workflow on KNIME Hub:

Br,
Ivan

3 Likes

Nice ipazin. It is easy and clear! Thanks a lot

1 Like

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