Verena Burger Posted January 6, 2023 Share Posted January 6, 2023 I am using Spotfire Analyst 11.8.0Ideally, there would be an option to apply a function once to the whole table, instead of using the "Trim" function on every column. I found this: Trimming White Spaces (tibco.com) but I can't find this menu option in my interface. Link to comment Share on other sites More sharing options...
Gaia Paolini Posted January 6, 2023 Share Posted January 6, 2023 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 transformationsselect: Calculate and Replace columnthen 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 https://docs.tibco.com/pub/sfire-cloud/latest/doc/html/en-US/TIB_sfire_bauthor-consumer_usersguide/bauthcons/topics/en-US/removing_operations_in_the_data_canvas.html# 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now