Jump to content

Recommended Posts

Posted

Hello Everyone,

 

I am a total newbie to IronPython in spotfire.

Problem:Description

I import a dataset with a lot of columns filled with irrelevant data, and then go ahead and remove around 10 columns everytime manually, during import (or sometimes later)

Ideally I would like to run a script which:

 

Imports data from a given file

Removes 2 rows

Removes 10 columns which I can specify

 

How do I do this Any help is appreciated , forgive me if I have overlooked a previos post about this topic.I could not find any.

Thank you All

Posted

Hi There,

It's possible to delete columns in IronPython:

 

from Spotfire.Dxp.Data import *

 

 

 

dataTable.Columns.Remove["My Column Name"]

 

myRowsToRemove = dataTable.Select('[My Column] = "Something"')

table.RemoveRows(myRowsToRemove)

 

You could also specify the rows to remove by creating an IndexSet. The above code selects rows with a certain condition and then deletes them. The syntax for Select is a bit like SQL.

Andrew (TIBCO Data Science)

  • 2 years later...
Posted

Hi, I am trying to remove rows from a data table based on a criteria defined by a document property. I tried using the above syntax but it gives an error. Can someone help with providing the correct syntax for the where clause. Document property is an integer type. Here's my code: selectedTag =Document.Properties["rowNum"]myRowSelection = dataTable1.Select('[RowID] = selectedTag')dataTable1.RemoveRows(myRowSelection)Errormsg:  File "<string>", line 218, in <module>

Exception: Could not find column 'upstream.SiteView.Regulatory_Compliance.selectedTag'.I modified the syntax to myRowSelection = dataTable1.Select('[RowID] ='+ """+selectedTag+""") but still no luckException: The expression is not valid after '' on line 1 character 23.

Spotfire.Dxp.Data.Exceptions.ExpressionParseException: The expression is not valid after '' on line 1 character 23. ---> antlr.NoViableAltException: unexpected token: ["",<1>,line=1,col=23] 

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