I’ve racked my brain with this a bit, and I haven’t come up with a solution that isn’t messy. The dataset has three columns, but I only want the first column split up into 2 datasets by the Boolean column which is column 3. So if Boolean is true then this item goes into dataset 1, else it goes to dataset 2. thanks
Not sure how messy is defined in this context, but this seems pretty short and sweet. And mostly painless.
Filter to 2 Tables_2018-12-07_1518.proj (28.6 KB)
if event.propertyName == 'data': dataIn = system.dataset.toPyDataSet(event.source.data) trueTable = event.source.parent.getComponent('True Table') falseTable = event.source.parent.getComponent('False Table') headers = ['value'] trueData =  falseData =  for row in dataIn: if row['Boolean Column'] == True: trueData.append([row['String Column']]) else: falseData.append([row['String Column']]) trueTable.data = system.dataset.toDataSet(headers, trueData) falseTable.data = system.dataset.toDataSet(headers, falseData)
I think @JordanCClark did it better, but:
# set up a dataset to run this against headers = ["H1", "H2", "H3"] data =  data.append(["a", 1, True]) data.append(["b", 2, False]) data.append(["c", 3, True]) data.append(["d", 4, False]) data.append(["e", 5, True]) dataset = system.dataset.toDataSet(headers, data) # here's the actual logic pds = system.dataset.toPyDataSet(dataset) trueData = [[row] for row in pds if row == True] falseData = [[row] for row in pds if row == False] trueDataSet = system.dataset.toDataSet(["H1"], trueData) falseDataSet = system.dataset.toDataSet(["H1"], falseData)
This was what I was leaning towards, I just hit a wall and couldn’t finish my logic. Thankfully it is Friday!!
I figured it was a Friday thing.
What is the need for this line?
Wait, is that so it only runs when the data property has changed?
You got it, my friend!