Jump to content

How can I trim whitespaces (in front & trailing) from an entire table in Spotfire?

Recommended Posts

The link you are referring to seems to apply to a different TIBCO product (Clarity).

I can suggest you try a couple of things:

A. If you don't mind applying the trim to your columns individually, go to the data canvas, select the data table in question, then click on the + sign (appearing on the line that links your data table to the output) and choose:

Add transformations

select: Calculate and Replace column

then type the expression: Trim([yourcolumnname]) and set the Column name to yourcolumnname so it gets replaced. Here yourcolumnname is whatever your column is called.

Repeat by adding a transformation for every string column.

B. Alternatively, you could use an IronPython script that does the same, and generates as many transformations as your string columns. You can for instance add a button to a textArea that executes the script. Note that if you keep applying it, it will repeat the transformations. To remove transformations manually from the canvas, see for instance this link


# Copyright © 2023. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from Spotfire.Dxp.Data import *from Spotfire.Dxp.Data.Transformations import * #identify data table form its name (table could be an input parameter of type Table, in that case comment next line)table=Document.Data.Tables['data'] #identify column names for columns of string data typestring_colnames=[]for col in table.Columns: if col.Properties.GetProperty('datatype')==DataType.String: string_colnames.append(col.Name) #loop through string columns and add a trim transformation for eachfor colname in string_colnames: column = DataColumnSignature(colname,DataType.String); t=ReplaceColumnTransformation(column, colname, "Trim(["+colname+"])") table.AddTransformation(t)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...