Product:TIBCO Spotfire Analyst
Versions:
Summary:
Write back to text file from TIBCO Spotfire using IronPython
Details:
?
Resolution:
Versions:
Summary:
Write back to text file from TIBCO Spotfire using IronPython
Details:
?
Introduction
Writing back to a text file can serve different purpose and different needs. The basic concept on how to write to a text file from Spotfire is using a StreamWriter
Exporting data from Cross Table, Table Plot or Summary Table
These visualizations have the ExportText method. With a few lines of code, we can export the data from these visualizations. Here is an example exporting data to a text file from a CrossTable:
from Spotfire.Dxp.Application.Visuals import CrossTablePlot
from System.IO import StreamWriter
targetFile = "c:\\temp\\test\\crosstable.txt"
writer = StreamWriter(targetFile)
crossTable = vis.As[CrossTablePlot]()
crossTable.ExportText(writer)
To append data to a file, keep the StreamWriter second argument as True to keep the stream open. Here is an example that writes a line to a text file
from System.IO import StreamWriter
#targetFileName = "\\\\company.com\\your\\folder\\ratings.txt"
targetFileName = "C:\\temp\\ratings.txt"
#Write to file
writer = StreamWriter(targetFileName,True) #True to append
writer.Write("hello world!")
writer.Close()
See also
References
- https://docs.microsoft.com/en-us/dotnet/api/system.io.streamwriter?view=net-6.0
- https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/tib_sfire-analyst_api/html/M_Spotfire_Dxp_Application_Visuals_CrossTablePlot_ExportText.htm
Resolution: