The Spotfire Community is moving to TIBCOmmunity and this forum location has closed. During the transition, you can still search the old forums but posting has been disabled. We encourage you to pick up the discussion at the new Spotfire community on TIBCOmmunity.
File Selection Dialog Via Python Script - TIBCO Spotfire Community

File Selection Dialog Via Python Script

Last post Thu, May 10 2012 6:35 AM by jcskalant. 16 replies.
Page 2 of 2 (17 items) < Previous 1 2
Sort Posts: Previous Next
  • Thu, May 10 2012 6:05 AM In reply to

    Re: File Selection Dialog Via Python Script

    Below is my full code. This allows to select a different excel file and changes the data in the Visualization

    I am avoiding this code "FileTable = Application.Document.Data.Tables.Add(uniqueName, flow)" because of the error

    In addition, how to handle if there are multiple Datatables?

    import clr
    import System
    clr.AddReference("System.Windows.Forms")
    from System.Windows.Forms import OpenFileDialog, MessageBox
    from Spotfire.Dxp.Data import DataType, DataTable, DataFlowBuilder, DataFlow, DataSourcePromptMode
    from Spotfire.Dxp.Data.Import import TextDataReaderSettings, TextFileDataSource

    #GETS THE FILE PATH FROM THE USER THROUGH A FILE DIALOG
    OpenFile = OpenFileDialog()
    OpenFile.ShowDialog()
    filename=OpenFile.FileName
    MessageBox.Show(filename)
    ds = Document.Data.CreateFileDataSource(filename)
    dfb = DataFlowBuilder(ds, Application.ImportContext)
    dfb.Execute(0, DataSourcePromptMode.RequiredOnly)
    flow = dfb.Build()
    DataTable = Document.Data.Tables["OTC"]
    DataTable.ReplaceData(flow)

    uniqueName = Application.Document.Data.Tables.CreateUniqueName("File Data Table")

     

    Jesus answered, “I am the way and the truth and the life. No one comes to the Father except through me. John 14:6
  • Thu, May 10 2012 6:35 AM In reply to

    • jcskalant
    • Top 10 Contributor
    • Joined on Sun, Aug 21 2011
    • Panam&amp;#225;
    • Posts 258

    Re: File Selection Dialog Via Python Script

    Cool John!

    Tks for sharing!

    JC

    Juan Carlos Escalante
Page 2 of 2 (17 items) < Previous 1 2
©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center