Marcio Souza Posted June 26, 2020 Share Posted June 26, 2020 Hi there! Is there any way to get column names from a data table and put them in a list using IronPython Cheers, Marcio Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted June 26, 2020 Share Posted June 26, 2020 The following script can help, from Spotfire.Dxp.Data import * colNames=[] table=Document.Data.Tables["myTableName"] for col in table.Columns: colNames.append[col.Name] Link to comment Share on other sites More sharing options...
Manoj Singh Posted June 26, 2020 Share Posted June 26, 2020 from Spotfire.Dxp.Data import * for eColumn in eDataTable.Columns: print eDataTable.Name + "tColumn: " + eColumn.Name Link to comment Share on other sites More sharing options...
Marcio Souza Posted June 26, 2020 Author Share Posted June 26, 2020 I got the following error running the suggested script. Traceback (most recent call last): File "<string>", line 7, in <module>TypeError: 'builtin_function_or_method' object is not subscriptableIronPython.Runtime.Exceptions.TypeErrorException: 'builtin_function_or_method' object is not subscriptable at CallSite.Target(Closure , CallSite , Object , Object ) Where line 7 is : colNames.append[col.Name]Any idea Link to comment Share on other sites More sharing options...
Marcio Souza Posted June 26, 2020 Author Share Posted June 26, 2020 I have noticed the issue. line 7 should be: colNames.append(col.Name) not colNames.append[col.Name] i have replaced [] by () and works. Thanks! Link to comment Share on other sites More sharing options...
Senthilnathan Eswaran Posted August 1, 2023 Share Posted August 1, 2023 The below code is working fine. But I tried to save the column names into the document property. It won't save. Please suggest here!!from Spotfire.Dxp.Data import *colNames=[]table=Document.Data.Tables["DataTableName"]for col in table.Columns: colNames.append(col.Name)Document.Properties['TestName'] == colNamesprint colNamesExample Output:['EEID', 'Full Name', 'Job Title', 'Department', 'Business Unit', 'Gender', 'Ethnicity', 'Age', 'Hire Date', 'Annual Salary', 'Bonus %', 'Country', 'City', 'Exit Date', 'AutoBinNumeric Test', 'Base64Decode'] 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