Try the Math.Round node assuming those are numbers, not text
If it is text use String.Split
1 Like
Since it’s a string, you can just replace the ".000000"
with an empty string (""
). If you have the value somewhere before converting to string you can also use python to convert the float to an integer.
2 Likes
I mean…Since we are all having a bunch of fun with this may as well throw a python example in.
Python Code
# List of Strings IN
# Example - ["2000.000000mm","2000.000000mm","2000.000000mm","2000.000000mm"]
string_list = IN[0]
# Function to remove text between "." and "mm" while keeping "mm"
def MMDot_Remove(input_string):
start_index = input_string.find(".")
end_index = input_string.find("mm")
if start_index != -1 and end_index != -1:
return input_string[:start_index] + "mm"
else:
return input_string
# Apply the function to each string in the list
NoDotMM = [MMDot_Remove(item) for item in string_list]
#Output after Def
#Expected result from example;
#["2000mm","2000mm","2000mm","2000mm"]
OUT = (NoDotMM)
3 Likes
Another solution…
This is quite nice as it’ll only remove the trailing zeroes and retain any actual values behind the decimal point if you don’t want to round them down.
3 Likes
I tried with great difficulty
import sys
lst=IN[0]
OUT = [str(round(float(lst[i][:-2])))+"mm" for i in range(0,len(lst))]
Cordially
christian.stan
1 Like
hello, I added the link in the node help for the syntax
cordially
christian.stan