Problem:
Starting from Spotfire 14.0, user can edit modify and view column description from Data in analysis flyout menu. A column description serves as metadata that provides explanations of what each column represents.
Is there a way to programatically update the value of multiple column descriptions at once?
Resolution:
This is possible using IronPython scripting. Read the instructions below.
1. Create an Excel file that contains following three columns:
- Table
- Column
- Description
2. Load the Excel file into Spotfire and rename the data table name to Description_Column.
3. Insert a text area into Spotfire analysis. Add an Action Control button that will execute the following script.
from Spotfire.Dxp.Data import *
table = Document.Data.Tables["Description_Column"]
TableCursor = DataValueCursor.CreateFormatted(table.Columns["Table"])
ColCursor = DataValueCursor.CreateFormatted(table.Columns["Column"])
DescCursor = DataValueCursor.CreateFormatted(table.Columns["Description"])
#iterate through table column rows to retrieve the values
for row in table.GetRows(TableCursor, ColCursor, DescCursor):
TargetTable = TableCursor.CurrentValue
TargetCol = ColCursor.CurrentValue
TargetDesc = DescCursor.CurrentValue
for t in Document.Data.Tables:
if t.Name == TargetTable:
table=Document.Data.Tables[t.Name]
for col in table.Columns:
if col.Name == TargetCol:
col.Properties.SetProperty("Description", TargetDesc)
|
4. Running the script will update the description of column LC/MS and ID in data table SAR assay data.
Comments
0 comments
Article is closed for comments.