List of numbers from Excel - "String from Object" adds decimals

Hi all,

Currently I am getting some some numbers (codes) from Excel, and once they go through “String from Object” there are many more decimal numbers therefore the code does not match when trying to create dictionary

The format of the cells in Excel have been set to general, integer and text but the additional decimal places only appear after the String from Object node. Is there a simple alternative? Right now I am making it work by cutting characters but I feel like I’m missing something

Two thoughts, first: what is the result of replacing the string from object node with a+“” in a code block? I have a vague recollection that this method doesn’t have the trailing zero issue.

If that doesn’t work than have a look at this:

1 Like

Using the code block still results with many zeros :frowning:

Thanks for the link, I will try this cheat hehe

codeblockstring

Use the spring nodes version:

5 Likes

Thanks for sharing, will save for next time I run into this issue!

The replace “0000” with “” worked most reliably

I was having the same issue importing from excel and string from Object. I found out that part of the problem was excel. You have to store your numbers as text in a way that it gives you an error with green little triangle on the top left corner of the cell in excel. To do this you have to first change the cell format to text and then only input your number value.

1 Like

This I noticed and wanted to see if there is a better solution.

You can change this by changing the number format in File > Preferences > General > Number Format. However, this is still a problem if, for instance, one wants to add these converted number strings to a Revit parameter using something like Element.SetParameterByName, since the decimal zeros are also added to the parameter value.

I have tried converting the integer to a string using Python to no effect.

In the example below, String.Length does not consider the decimal zeros for integers, but the float with one decimal returns a length of 8 characters. This is very odd… Does anyone know why this happens and how to fix it or at least work around it? Thanks.

It’s a known issue with display of integers, where values receive extra zeros when displayed. Has already been fixed in a future build.

2 Likes