Frank Schmitt
Frank Schmitt

Reputation: 30815

How to avoid "System.ArgumentException: Not a valid expression" when using a colum name with square brackets in Spotfire SDK?

I've got a working IronPython script for loading an Excel file and adding its contents to an existing data source. When loading the Excel file, I'm using a DataFlowBuilder with an ExpressionTransformation to perform some data conversions, e.g. converting columns from Int to Real.

This works unless the column name contains square brackets - whenever I try to use a name containing square brackets, I get a "System.ArgumentException: Not a valid expression: Cast([Process Time [h]] as Real)" exception (where "Process Time [h]" (without the quotes) is the name of the Excel column).

CODE

transformation = ExpressionTransformation()

transformation.ColumnReplacements.Add(
         "Process Time [h]",
         "Cast([Process Time [h]] as Real)",
         ColumnSelection([DataColumnSignature("Process Time [h]", DataType.Integer)])
)  

Things I've tried

Any ideas? Or should I contact Tibco Spotfire support regarding this?

Upvotes: 1

Views: 620

Answers (1)

Nicolas Stefaniuk
Nicolas Stefaniuk

Reputation: 248

Cast([Process Time [h]]] as Real) should work. Note the unbalanced number of [ and ].

Upvotes: 3

Related Questions