Jump to content
We've recently updated our Privacy Statement, available here. ×

Working on a script replace SAS datasets, hoping to configure whether the SAS name or the SAS description is used for Spotfire column names. This option is represented as a checkbox on the Spotfire SAS Data Import UI.


Alex Weir 2

Recommended Posts

# Seems by default SAS description is applied as column names in the script below

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Data.DataOperations import *

from Spotfire.Dxp.Data import DataFlowBuilder

from Spotfire.Dxp.Application import DocumentMetadata

from Spotfire.Dxp.Data.DataOperations import DataOperation

from Spotfire.Dxp.Application.Visuals import HtmlTextArea

from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItem, LibraryItemRetrievalOption

lm = Application.GetService(LibraryManager)

from System import Guid

for tbl in Document.Data.Tables:

 sourceView = tbl.GenerateSourceView();

 try:

 op=sourceView.GetAllOperations[DataSourceOperation]()[0]

 except:

 pass;

 if type(op).__name__ == 'DataSourceOperation':

 t=op.GetDataFlow().DataSource

 try:

  if (t.FilePath == None):

  path="Clipboard"

  else:

  path=t.FilePath

  print path

  updatedPath = path.replace("import\","import\Migration_Test\")

  dataSource= Document.Data.CreateFileDataSource(updatedPath)

  dataFlow = DataFlowBuilder(dataSource, Application.ImportContext).Build()

  if op.CanReplaceDataFlow():

 op.ReplaceDataFlow(dataFlow)

 except:

  print "NA";

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