Taking Table Data without Headers

Hi all,

I have a table full of data that I want to take out and put into an array. I initially put the data inside with a system.dataset.toDataSet(headers,data) function. Unfortunately, I am unable to now take the data out without the headers. e.g. it comes out as header: data instead of just data.

I tried to use the system.dataset.toDataSet without the header input but the data does not show up correctly. Any tips or solutions?

Is your script in the view or on the gateway? If it’s in the view then I would be using

Its on the view. This makes sense thank you - I went one way with the self.getSibling and completely forgot that I could go backwards to pull the data out again. Cheers

Just tested this, unfortunately it still brings in the column (title) in. Additionally, it includes the data inside as an array, with square brackets. e.g. comes out as [“data”] while I want the output to be “data”. Unfortunately I cannot use the remove function as my data has square brackets inside the string which I’d like to keep.

It would be useful to see your code. I suspect its a similar situation as our other topic, you have an object but think you have a value.

Hi, I’ve attached the following code to make things clearer.
Here is the code where I go into the tag and take data to put into the table: (Ignore the funny bit around line 12 it didn’t import nicely)

path = []
tagDataset = []
blank = []
tagPath = []

#Set  header for table
tagHeaders = ['Items']

#Browse to location of Control Modules and read all tags
browseTagArray = system.tag.browseTags("FolderA/FolderB/ItemNames", type = "")

#Go through the tags and write path to an array
for tag in browseTagArray:

#Read all tags in this array through path
values = system.tag.readAll(path)

for browseTag, QualifiedValue in zip(browseTagArray, values):

pathInfo = system.dataset.toDataSet(tagHeaders, tagPath)

table0 = self.getSibling("Table_0")
table0.props.data = pathInfo

#Call the table data (originally was put in a different event)
paths = self.getSibling("Table_0").props.data

This is what the table will look like
This is how I call the table info (on the press of a button)
and finally, the output of the previous code

What I would like to do is get the data as is from the table, in string form as an array e.g. [’[default]FolderA/FolderB/ItemNames/ItemA’ , ‘[default]FolderA/FolderB/ItemNames/ItemB’,…]

(Updated with code in text)

Tip: post code, not pictures (unless it helps some other context). Use the </> code formatting button to preserve code indentation and apply syntax highlighting. That way we can copy and paste the code into our answers.

Is this the actual code you use, or did you change/remove things before posting it here ?
The results from the tag reads are never used !

The whole thing can be simplified to this:

headers = ['items']
paths = [tag.fullPath for tag in system.tag.browse("folder/path/")]

dataset = system.dataset.toDataSet(headers, paths)
table0.props.data = dataset
paths = self.getSibling("Table_0").props.data

Now, to answer your specific question, if you get a list of dictionaries and only want the values, well…

[dict.values() for dict in list_of_dicts]

And if you want a list with the value of one key and not a list of lists:

[dict['key'] for dict in list_of_dicts]
1 Like

Sorry yeah, I changed things around due to privacy issues surrounding the tag/folder names - I tried to keep it consistent but I may have missed something - my apologies