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

Script to import contents from text file or csv file


Rasheed Bello

Recommended Posts

To add a csv file as a data table, you can use the below script as reference

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Data.Import import *

 

filePath=r"C:sample.csv"

#specify any settings for the file

settings= TextDataReaderSettings()

dataSource=TextFileDataSource(filePath,settings)

 

dataManager=Document.Data

#datasource name and datasource to add table

dataManager.Tables.Add("myNewDataTable",dataSource)https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/topic=html/T_Spotfire_Dxp_Data_DataTableCollection.htm

https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/topic=html/T_Spotfire_Dxp_Data_Import_TextFileDataSource.htm

https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/topic=html/T_Spotfire_Dxp_Data_Import_TextDataReaderSettings.htm

Link to comment
Share on other sites

You need to specify the TextDataReaderSettings as needed. For example since this is a CSV file the separator would be a comma so you need to add the below code

 

settings==TextDataReaderSettings()
settings.Separator=","

 

https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/topic=html/T_Spotfire_Dxp_Data_Import_TextDataReaderSettings.htm

 

In a similar way you can configure the other available settings. You can refer to the above documentation for the available properties that can be configured

Link to comment
Share on other sites

Thanks. can you direct me to a document that breaks down the Spotfire property scripting. The document link above is not helpful. I mean a document with examples that breaks down the syntax like any other program. e.g. where do the Constructors go, Properties, Methods, Events. wWhat is the right syntax

 

I cannot find any helpful document online.

 

Spotfire.x.x.xxx..

 

   from x.x.x.

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