Write back to text file from TIBCO Spotfire using IronPython

Write back to text file from TIBCO Spotfire using IronPython

book

Article ID: KB0072140

calendar_today

Updated On:

Products Versions
Spotfire Analyst -

Description

 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

Issue/Introduction

Write back to text file from TIBCO Spotfire using IronPython