Skip to main content
Version: 7.9

system.dataset.toDataSet

This function is used in Python Scripting.

Description

This function is used to

  1. Convert PyDataSets to DataSets
  2. Create new datasets from raw Python lists. When creating a new dataset, headers should have unique names.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax (Without Headers)

system.dataset.toDataSet(dataset)

Parameters

TypeParameterDescription
PyDataSetdatasetA PyDataSet object to convert.

Returns

Dataset - The newly created dataset.

Scope

All

Syntax (With Headers)

system.dataset.toDataSet(headers, data)

Parameters

TypeParameterDescription
PySequenceheadersA PyDataSet object to convert.
PySequencedataA list of rows for the new dataset. Each row must have the same length as the headers list, and each value in a column must be the same type.

Returns

Dataset - The newly created dataset.

Scope

All

Code Examples

Example 1
# This example create a single column dataset.

header = ['myColumn']
rows = [[1], [2]]
dataset = system.dataset.toDataSet(header, rows)
Example 2
# This first example shows how this function can be used to convert from a PyDataSet (which is what system.db.runQuery returns) to a normal DataSet, which is the datatype of a Table component's data property.

pyDataSet = system.db.runQuery("SELECT * FROM example1 LIMIT 100")
table = event.source.parent.getComponent("Table")
normalDataSet = system.dataset.toDataSet(pyDataSet)
table.data = normalDataSet