Hello All,
Thank you very much to everyone who has helped me so far today. I am now trying to combine the datasets that I had previously stored as dataset tags. However, when I try to append their together, I get a really strange result. I have attached what my first two datasets looked like when I stored them in the tags. When I store them, it also shows the weird structure within the tag itself. Does anyone know why it is doing this? Additionally, does anyone know if there is a way when you create tags from the script editor, if it is possible to specific the data type as a dataset, instead of having to go and manually change it?
Example code showing how I sent the stored the data in the dataset tag:
idata = system.file.openFile('json')
bytes = system.file.readFileAsBytes(idata)
from org.apache.commons.io.input import BOMInputStream
from java.io import ByteArrayInputStream, ByteArrayOutputStream
from java.lang import String
bomInput = BOMInputStream(ByteArrayInputStream(bytes))
outputStream = ByteArrayOutputStream(len(bytes))
bomInput.transferTo(outputStream)
bytesOut = outputStream.toByteArray()
strOut = String(bytesOut, "utf-8")
obj = system.util.jsonDecode(strOut)
newlod = [{d['Term']: d['Estimate']} for d in obj]
headers, data = zip(*[d.items()[0] for d in newlod])
ds = system.dataset.toDataSet(headers, [data])
print(ds)
event.source.parent.getComponent('Power Table').data = ds
# The provider and folder the Tag will be placed at.
baseTagPath = "[default]Coefficients"
# Properties that will be configured on that Tag.
tagName = "MLR"
valueSource = "memory"
Value = ds
sampleMode = "TagGroup"
tagGroup = "Default"
# Configure the tag.
tag = {
"name": tagName,
"value" : Value,
"valueSource": valueSource,
"sampleMode" : sampleMode,
"tagGroup" : tagGroup
}
# Set the collision policy to Abort. Thus, if a Tag already exists at the base path,
# we will not override the Tag. If you are overwriting an existing Tag, then set this to "o".
collisionPolicy = "o"
# Create the Tag.
system.tag.configure(baseTagPath, [tag], collisionPolicy)