String remove last characters

Dear Dynamo Team,
one more question please. How can i remove last 0 values of string list. Please see photo:

If it’s always 3 zeroes than this will suffice:

7 Likes

On a side note: I assume you’re getting the trailing zeroes because you’ve converted a double value to a string. In that case you could also use this python code to get what you want straight away:

2 Likes

Hello,
Thank’s for ur proposition
I tried but i had a problem
My list is coming from an excel sheet

You have empty places in your list… that causes the error… (and gives “null”) as you cannot remove 4 characters from nothing…

But you should not use this method for rounding as it does not round but rather remove characters…

1 Like

Not working, thnx

You’re probably using strings not numbers/doubles, strings cannot be rounded as they are “text”-based…

Next time instead of just writing “not working”… which is kinda rude, include a screenshot of what is not working so we have a chance of helping you correctly and not just guess what you’re actually doing…

1 Like

image

Yes you’re right, it’s because of my Replacebycondition node to take off my null values.

Thnx

PS: Have you an idea about how to get my first item different of the others ? (the 35/40 value)
image

You could do something like:

1 Like

I used this, thank’s for the drop item node :slight_smile:

Just an addition, if you cant to save some space:

Jonathan,
can u tell me how can i get the round of my values on the list ?


Ex :
516,469038 -> 520
1106,719368 -> 1110
An idea ?
Thnx

That was proposed by @m.rijsmus earlier in this post :slight_smile: You just need to make sure that you’re rounding “numbers” and not “strings”…

But that is not just rounding you’re looking for that is approximation to nearest 10

1 Like


The problem is my null values

But even though there is an error your result is correct (and will work downstream just as well).

Alternatively you can replace the null’s prior to rounding…

Found something
thnk’s a lot

You can also use the “Math.Round+” from clockwork to round to nearest 10…

image

Please do not just write “found something” share what you’ve found and help future people having similar issues…

True !
Indeed, but what i changed was on my excel sheet