I am trying to to take an array that i would use for a dataset and use it to push into a dataset tag
Here is the code I am currently running and
data = []
if len(myparams) > 0:
headers = myparams[0].keys()
for row in myparams:
rowdata = []
for key,value in row.items():
rowdata.append(value)
data.append(rowdata)
ds = system.dataset.toDataSet(headers,data)
event.source.parent.getComponent('Power Table').data = ds
I want to do something like
data = []
if len(myparams) > 0:
headers = myparams[0].keys()
for row in myparams:
rowdata = []
for key,value in row.items():
rowdata.append(value)
data.append(rowdata)
ds = system.dataset.toDataSet(headers,data)
system.tag.write("tagdata", system.dataset.setValue(ds, row, col, newVal))
Not sure what I am missing.
I am not seeing where you are writing anything to a database. Looks like you are converting a list into a dataset and attempting to write that to a tag.
@josborn Correct, I changed my scope after I started. I had been planning on writing to a SQL table but I can get by just writing to a dataset memory tag. I have edited to match my scope change.
I have a dataset of about 20 columns and 140 rows that I want to move into the dataset tag once a day.
What’s the last line supposed to be doing, its outside of your loop, and the indentation looks wrong. Writing a dataset to a tag is pretty straight forward, why not just system.tag.write("tagdata", ds)
1 Like
Welp, I thought I had tried just that but I must have missed something. It worked just as it should.
I thought it should be that straight forward.
The indent wasn’t in my actual code, it was in the right spot.