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.
The new NodeBox forum is live! Everything from support.nodebox.net moved here: sign in with the same email to pick up your old posts. Something not working? Write to forum-support@nodebox.net.
General DiscussionFrom the old forum
Converting time strings into numbers
-
-
NodeBox team We need time nodes!
Do you just have hours and seconds? Do you want to have a full day converted to 360 degrees?
-
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
-
NodeBox team 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
tand splits it on the ":". This separates the hours from the minutes. Hours are stored in a variableh, minutes are stored in a variablem. - 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: https://vimeo.com/89486032
- First, it takes the input value
-
Brilliant! Many Thanks!