Сохранение пользовательского ввода в spotfire - PullRequest
0 голосов
/ 07 апреля 2020

Можно ли сохранить данные из пользовательских данных в Spotfire? Я имею в виду, могу ли я попросить пользователя предоставить оценку данного отчета? Или я могу сохранить какую-то другую информацию, такую ​​как веб-браузер, ОС и т. Д. c. никак на сервере?

1 Ответ

0 голосов
/ 08 мая 2020

Вы можете использовать сценарий python для добавления данных в таблицу данных в Spotfire.

Используя копирование и вставку, создайте таблицу в spotfire (без значений, только заголовки), скажем, два столбца Rank и Comment. Затем создайте два свойства документа, по одному для каждого столбца.

Добавьте кнопку для запуска сценария добавления, чтобы взять два свойства документа и добавить в таблицу данных.

скрипт python будет выглядеть так:

from Spotfire.Dxp.Data import AddRowsSettings
from System.IO import  StreamWriter, MemoryStream, SeekOrigin
from Spotfire.Dxp.Data import DataType, DataTableSaveSettings
from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings

x = Document.Properties['Rank']
y =Document.Properties['Comment']


print(x,y)

#Create some data with columns that match an existing table to which new rows need to be added. 
textData = "Rank,Comment,\r\n"+x+","+y+"\r\n" 
print(textData)

#Using a Memory Stream as a placeholder to write the columns to which can then be used to make a data source
stream = MemoryStream()
writer = StreamWriter(stream)
writer.Write(textData)
writer.Flush()
stream.Seek(0, SeekOrigin.Begin)

#Settings to tell the system the data types being imported.Here it is defined as a comma separated list of column index and their data types
readerSettings = TextDataReaderSettings()
readerSettings.Separator = ","
readerSettings.AddColumnNameRow(0)
readerSettings.SetDataType(0, DataType.String)
readerSettings.SetDataType(1, DataType.String)

textDataSource = TextFileDataSource(stream,readerSettings)

#Use settings here to automatically have the system match column names between the data table and the memory data source created above.
settings = AddRowsSettings(Document.ActiveDataTableReference,textDataSource)

#Add the rows from the datasource.
Document.ActiveDataTableReference.AddRows(textDataSource,settings)
...