Export Table/Cross Table visualization data (in memory or in database) in csv file, conditional export can also be achieved by accessing the cell data values and adding conditions.
Introduction
Export Table/Cross Table visualization data (in memory or in database) in csv file, conditional export can also be achieved by accessing the cell data values and adding conditions.
Code Sample
# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from System.IO import * from Spotfire.Dxp.Application.Visuals import VisualContent # visual is a Script parameter for Table/Cross Table visualization vc=visual.As[VisualContent]() memStream = MemoryStream(); sWriter = StreamWriter(memStream); # Exporting the data to Memory Stream vc.ExportText(sWriter); #exports data in tab separated text sReader = StreamReader(memStream); memStream.Seek(0, SeekOrigin.Begin); filename="C:UsersadminDownloadsspotfireexport.csv" f=open(filename,"w") counter=0 j=0 str1='' while (sReader.Peek()>=0): line=[] counter=counter+1 #counts the number of rows in dataset a=sReader.ReadLine() lines=a.split("t") for elem in lines: j=j+1 # counts the number of columns in dataset print elem if str(elem).find(",")<>-1: elem='"'+elem+'"' # escaping comma already present in string line.append(elem) str1 = ','.join(str(e) for e in line) f.write(str1+'n') f.close(); MemoryStream.Dispose(memStream); sReader.Close()
References
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.