spotfire :How to use a dictionary to create extra columns in iron python

Viewed 457

I have been successful in creating calculated columns before, but now I need to create a column based on input from a dictionary.

My scenario: I have a table that has a special column with values that I need to use to create my new column.I need to go down that special column, row by row, and as I consider each value, I need to create a corresponding value in the new column that is based off the dictionary.

Example: in my special column "category" the first value is "P1", therefore my code would produce a row on that same line, but in a new column called "newColumn" and the value would be equivalent to the dictionary value: dict[p1]

so this code would go down the column "category " while automatically populating "newColumn" which the dictionary values.

All the codes I have seen here on stack overflow, have been based off of other columns purely, and not other structures such as dictionaries.I have tried using a calculated column as well but it does not recognize my column name "Category" within the dictionary and it just looks wrong , here is the example of it:-

expression = 
mydict["DataValueCursor.CreateFormatted(activeTable.Columns[Category])"]
[0]

cols = Document.Data.Tables["myTable"].Columns      
cols.AddCalculatedColumn("newColumn",expression)   

MessageBox.Show("Column created succesfully!!")

also please be as elaborate as possible, I am still new to spotfire

0 Answers
Related