I have scripted a button to pull a dataset from a table to insert data into memory tag dataset. This is working. Now i am trying to insert certain row or rows with "Cold Side" from tag into new table. This would be in "Place" column of the dataset. Can you please help or know of an easier way to do this?
pyData = system.dataset.toPyDataSet(event.source.parent.getComponent('Table').data)
for row in pyData[1:]:
Place = row
if Place == 'Hot Side':
Table Script trying to pull one row out of the dataset tag:
data = system.tag.read("[default]Test/Table_Pass").value
smalldata = system.dataset.setValue(data, ["Cold Side"])
event.source.parent.getComponent('Table 1').data = smalldata
PyDatasets, like Datasets, are immutable - you can't directly change what they contain. You should use a similar approach to what you're currently doing with
system.dataset.setValue in the table script.
If you want to add an entire row, you should use the scripting function dedicated to the purpose:
I am just trying to pull a row out and save to a tag. The dataset looks like the following..
[Header] Place Qty
 Hot Side 1
 Cold Side 2
So row 2 is Cold Side. I want to take that row calling "Cold Side " and get the whole row. Then save that row to Cold Side tag just with that information. I'm not trying to change data. I just don't know how to do this. I'm not great with scripting so just asking.
What type is the tag; dataset? If it's a dataset, do you want the row you extract from the table to be appended, or just set as the only row on the new tag?
I have a memory tag with a data type of dataset. I can pull the whole table into here. I don't know which would be better to have because i want to just tie the tags to a different tables. One table will be Cold Side and the other is Hot Side. I am guessing a tag might be better to do.
How big (number of rows) will the table be?
If the tag is of type dataset, it is still (basically) immutable. You will need to create a new dataset with the information you want to store, and then write the entire dataset to the tag.
It will probably be 5 rows or 6 rows. I don't know how to make the new dataset to depict each row to a tag. That is my problem. I can get a full table to the tag. I don't know how to break the dataset in rows to go to multiple datasets(tags).
The first thing I would ask is, is there any reason that you need that information saved globally outside of the application? If not, then I wouldn't save it to a tag, just a property.
If your going to do it at the application level is it vision or perspective?
It is vision but want the values to go to different windows. This is why i want to break it down and then tie it to each new table with just the data applied to each window. I don't know which way is best. I'm not great at scripting so trying anything to make it work.
Do you actually need the entire row, or just the value? A lookup expression may do the trick for you.
Use the lookup expression function for single columns. It is the most efficient tool. For whole row or rows, consider using my
view() expression function from my Simulation Aids Module. When placed in DEBUG mode, it will report the jython it uses under the hood to execute your pseudo-SQL. You can copy and paste into a script module to customize or to use where my module is not appropriate.