Jump to content

Create Data Table with certain columns included


Romain Falluret

Recommended Posts

I have been searching for a way to create a new table from an existing one, but only with certain columns included. However, I have not found a solution yet. 

I have included my scripts in an attachment.

I already checked this post and it help me to create the new table but with all columns.

https://community.spotfire.com/wiki/how-add-new-data-table-based-existing-data-table-analysis-tibco-spotfirer-using-ironpython

Link to comment
Share on other sites

Hello,

You could use an ExcludeColumnsTransformation transformation for that (you don't specific what columns to include, but rather which ones to exclude).

Here's a basic example of that:

from Spotfire.Dxp.Data.Transformations import ExcludeColumnsTransformation

from Spotfire.Dxp.Data import DataColumnSignature, DataType

from System.Collections.Generic import List

print "The data table " + table.Name + " has " + table.Columns.Count.ToString() + " columns before."

#Define columns to exclude

list = List[DataColumnSignature]()

list.Clear()

col = table.Columns['Country Name']

list.Add(DataColumnSignature(col))

excludeColumns=ExcludeColumnsTransformation(list)

# add transformation

table.AddTransformation(excludeColumns)

print "The data table " + table.Name + " has " + table.Columns.Count.ToString() + " columns after."

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...