Converting time strings into numbers

's Avatar


13 Mar, 2014 02:12 PM

From a CSV, I have got a list of times in the format MM:SS, but I wish to convert these times to values that I can use for the radiuses of circles. Any ideas how I can achieve this.

  1. Support Staff 1 Posted by Frederik De Ble... on 18 Mar, 2014 08:48 AM

    Frederik De Bleser's Avatar

    We need time nodes!

    Do you just have hours and seconds? Do you want to have a full day converted to 360 degrees?

  2. 2 Posted by tomshorey on 18 Mar, 2014 04:16 PM

    tomshorey's Avatar

    from these times I want to create circles with the radius proportional to the time... so 1:00 equals a radius of 1... 2:30 equals a radius of 2.5

    I've attached the .csv... the field I want to use is the timeto field

  3. Support Staff 3 Posted by Frederik De Ble... on 19 Mar, 2014 09:26 AM

    Frederik De Bleser's Avatar

    This requires a bit of custom code. Here's a custom Python script that does the conversion:

    def time_to_value(t):
        h, m = t.split(":")
        return int(h) * 60 + int(m)

    What it does:

    • First, it takes the input value t and splits it on the ":". This separates the hours from the minutes. Hours are stored in a variable h, minutes are stored in a variable m.
    • Note that these are still strings, so we need to convert them to integers. This is done using int(h).
    • Since one hour is equivalent to 60 minutes, we multiply the hours by 60 and add the minutes.

    I've uploaded a video that shows the process of creating a custom node and how to link it to NodeBox:

  4. 4 Posted by Tom Shorey on 19 Mar, 2014 10:49 AM

    Tom Shorey's Avatar

    Brilliant! Many Thanks!

  5. Frederik De Bleser closed this discussion on 20 Mar, 2014 09:46 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

25 May, 2024 11:52 AM
24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM


13 May, 2024 12:36 AM
12 May, 2024 07:46 PM
05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM