Я использую сценарий Iron Python для экспорта кросс-таблицы Spotfire для превосходного вывода.
Перед экспортом я добавляю заголовки, а затем содержимое таблицы. при добавлении хэдинга есть ли способ слияния ячеек и экспорта
Я использую приведенную ниже строку
Heading10 = ',,,' + 'All Funds' + ',,,' + 'Benchmark' + ',,,, Атрибуция производительности ,,, Разница'
и токовый выход
Но я ожидаю выхода, как показано ниже.
Есть ли способ сделать это?
Используемый мной скрипт:
from System.IO import *
from System import Environment, Threading
import clr
from Spotfire.Dxp.Application.Visuals import TablePlot, HtmlTextArea
import clr
from Spotfire.Dxp.Application.Visuals import VisualContent
vc=Visuals.As[VisualContent]() #Visuals = Script parameter for
Table/Cross Table visualization
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);
#Column Header heading 4&5 are calculated column and will generate the value based on user selection. also i have if else condition for Heading 10
Heading10=',,,'+Heading4+',,,'+Heading5+',,,,Attribution,,,Difference'
Filenm = 'Export_csvOutput.csv';
newtemp ="\\\\share1\\folder1\\"
filename=newtemp+Filenm
print filename
f=open(filename,"w+")
counter=0
j=0
str1=''
f.write("Attribution Dashboard"+'\n')
f.write(Heading2+'\n') #Subheading1
f.write(Heading3+'\n') #Subheading2
f.write(Heading6+'\n') #subheading3
f.write("US Dollar"+'\n')#subheading5
f.write('\n'+'\n')
f.write(Heading10+'\n')
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()