String remove last characters

#1

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

0 Likes

#2

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

3 Likes

#3

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

Python Nodes Basics
#4

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

0 Likes

#5

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

#6

0 Likes

#7

Not working, thnx

0 Likes

#8

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

#9

image

0 Likes

#10

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

0 Likes

#11

You could do something like:

1 Like

#12

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

0 Likes

#13

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

0 Likes

#14

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

0 Likes

#15

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

#16


The problem is my null values

0 Likes

#17

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…

0 Likes

#18

Found something
thnk’s a lot

0 Likes

#19

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…

0 Likes

#20

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

0 Likes