Python Node loses column types

I use a Python Script (1 => 1) Node and sometimes the input table is empty. When this is the case a column that was Double before is suddenly a string.
Is there a way to retain the column types?

My solution was to use an empty table switch afterwards. If the table is empty I add a row with just 0.1, then use String to Number to convert the column I need in double to double and then drop all rows again. This results in the column being double again.
But I’m sure there is a better way, does somebody have an idea?

Hi @ChrisHill

I created a workflow losing_keeping_column_types.knwf (17.9 KB) where the test-table in both situation (empty or not-empty, keeps the column type (a double). Is this what you are looking for?
python_column_type

gr.
Hans

2 Likes

Nice thank you!
Of course the solution was to use the Empty Table switch BEFORE my Python Script. Somehow I didn’t think of this.
Thank you very much!

Best
Christoph

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.