Converting empty index to integer at particular indices

Hi everyone, this is my last milestone in the graph of editing family parameter values. I am feeding data from csv file. As all values are in string, I utilized this code to convert it to default characters (after minor customization).

As seen below, except indexes [2], [5] and [7], all other must be of int. type. In general they are taking proper type but when there is empty value it is turning to string and throwing error. I want to avoid this behavior by making them int. type whenever the index is empty.

For index 6, I managed to slice off extra “inches” to achieve required type.

1 Like

for the converting use python:

nums = []

for i in IN[0]:

OUT = nums


I have to convert only particular indices as three of them has to be string type. I guess, if I take particular index and convert it to float and return back to list, that would work.

Also, I tried your for loop on my list, it is returning error

ValueError: invalid literal for float():

1 Like

At least i know this way …

How to deal with “nothing”… :slight_smile:

1 Like

Hi @shujath36 ,

Have you thought about removing those values entirely from your list?
I’m assuming you want to use your values in an “SetParameterValue” node, if the values which cause problems are empty, wouldn’t removing them solve this issue?

No @Daan , the empty index is different for every instance of list. Can’t get away with that.

Even with a setup like this?

Also, maybe working with Dictionaries would help out here, to easily identify when to translate a string into a number (or when NOT to):

2022-04-11 String to Number with If-Condition.dyn (20.0 KB)


Thanks @Daan you made my day! FilterByBoolMask was handy one.

1 Like