Jump to content
  • How to read data from a Web Service and save the data in Spotfire® Using IronPython Scripting

    Code snippet that reads CSV data from an web services and saves the data as a data table into the analysis.


    Below is snippet which reads CSV data from an web services and saves the data  as a data table into the analysis.

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    import clr
    from System.IO import *
    from System.Net import HttpWebRequest, NetworkCredential
    from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings
    req = HttpWebRequest.Create("http://server-port/fileName.csv"")
    user_agent = 'individual user-agent'
    req.Method = "GET"
    req.UseDefaultCredentials = True
    readerSettings = TextDataReaderSettings()
    readerSettings.Separator = ","
    readerSettings.CultureName = "en-GB"
    rsp = req.GetResponse()
    dSource = TextFileDataSource(rsp.GetResponseStream(),readerSettings)
    for table in Document.Data.Tables:
    		if table.Name == "dataFromWebService":
    			tblfound = "true"
    if tblfound == "false":
    if tblfound == "true":
    rsp.Close ();


    License:  TIBCO BSD-Style License



    User Feedback

    Recommended Comments

    There are no comments to display.

  • Create New...