Jump to content

adding a blank column using ironpython


Sundaram Sridharan

Recommended Posts

I need to check if a column is present (which came in through a pivot operation) and if not I need to add it to the table with blank values for all rows. I am looking for syntax of table.AddColumns for this (what is datasource here).

Also can this be only triggered by an action item in text area Ideally I would like to add this as a transform right after pivot in data canvas.

Link to comment
Share on other sites

Try this (replace column names and data types as required): check the indentation (got mixed up when pasting)

 

from Spotfire.Dxp.Data import *

desiredColsDict =

{'mydatecol':DataType.Date,'myintegercol':DataType.Integer,'mystringcol':DataType.String}

for key,value in desiredColsDict.items():

try:

expression = str(value)+'(NULL)'

dataTable.Columns.AddCalculatedColumn(key,expression)

except:

pass

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