Import or copy 3 arrays into one dataset

Hello, I have 3 array tags that I would like to compile into one dataset. They are all an array of 32. The first array is a Boolean (true, false), the other two are strings. Is this possible? I can only find examples of created arrays from datasets and dataset manipulation. Thanks

You want each array to be its own column in the dataset? Absolutely possible. You’ll want to use the system.dataset.toDataset() function - something like this might work directly, though I’ll admit it’s untested:

tags = [
	"path/to/boolArray",
	"path/to/stringArray1",
	"path/to/stringArray2"
]

values = system.tag.readBlocking(tags)

headers = ["booleanArray", "stringArray1", "stringArray2"]

dataset = system.dataset.toDataset(headers, values)

Hello, I should have mentioned I’m on 7.9.12.

7.9 will use readAll() instead of readBlocking. You’ll also need something to convert the data to a tall format.

tags = ["path/to/boolArray",
	    "path/to/stringArray1",
	    "path/to/stringArray2"
	   ]
	   
values = [list(tag.value) for tag in system.tag.readAll(tags)]

headers = ['bool', 'string1', 'string2']

# Convert from wide to tall
data =[row for row in zip(*values)]

dataset = system.dataset.toDataSet(headers, data)
2 Likes

I ended up with this:

I created a table. I passed in 3 parameters to a custom method. I applied the below script to a table. I made an expression on the [data] part of the table as runScript(buildDataset,0)

headers = ['value','address','description']
data = []
for i in range(len(inputs)):
	row = [inputs[i],addresses[i],desc[i]]
	data.append(row)
return system.dataset.toDataSet(headers,data)

Thanks, Darren