# Show Only "True" Rows in Perspective Table

**URL:** <https://forum.inductiveautomation.com/t/show-only-true-rows-in-perspective-table/72362>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [April 12, 2023, 3:31pm UTC](https://forum.inductiveautomation.com/t/show-only-true-rows-in-perspective-table/72362 "2023-04-12T15:31:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio\_graham](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@antonio\_graham](https://forum.inductiveautomation.com/u/antonio_graham)\
**Post date:** [April 12, 2023, 3:31pm UTC](https://forum.inductiveautomation.com/t/show-only-true-rows-in-perspective-table/72362/1 "2023-04-12T15:31:09Z")

</div>

Hello! **I have 2 questions for the same perspective table.**

1. How can I only show ONLY "True" rows in my perspective table? I wrote a script to add a new column that's shows which values are within a specific range here by Add Transform+:

```auto
def transform(self, value, quality, timestamp):
inrangelist = []
	colCount = value.getColumnCount()
	for row in range(value.getRowCount()):
		if 16 < value.getValueAt(row,1) < 27:
			inrangelist.append(True)
		else:	
			inrangelist.append(False)
	newDataset = system.dataset.addColumn(value, colCount, inrangelist, "results", bool)	
	return newDataset

```

But I only want to show which rows are "True". If I remove the else: statement I get a Error\_ScriptEval numbers of values does not match number of rows.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/7/57564dbad95186e59c98a52bf8cbc51eed62c2e2.png)

1. In the same Table how can I convert my "t\_stamp" column to a date and time that's readable in Python. Existing **t\_stamp:1680700299058**  
I need the time readable to reflect: **Wed Apr 05 2023 09:11:39 GMT-0400 (Eastern Daylight Time)**  
Thanks

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 12, 2023, 3:47pm UTC](https://forum.inductiveautomation.com/t/show-only-true-rows-in-perspective-table/72362/2 "2023-04-12T15:47:43Z")

</div>

Tip: edit your question, select the code block and click the \</\> code formatting button. It will preserve indentation and apply syntax highlighting.  
Use `2.` rather than `2)` for numbered list.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 12, 2023, 4:17pm UTC](https://forum.inductiveautomation.com/t/show-only-true-rows-in-perspective-table/72362/3 "2023-04-12T16:17:39Z")

</div>

One of many options:

```python
def transform(self, value, quality, timestamp):
	in_range_values = 0
	out_of_range_indices = []
	colCount = value.getColumnCount()
	for row in range(value.getRowCount()):
		if 16 < value.getValueAt(row,1) < 27:
			in_range_values += 1
		else:	
			out_of_range_indices.append(row)
	rowsRemoved = system.dataset.deleteRows(value, out_of_range_indices)
	newDataset = system.dataset.addColumn(rowsRemoved, colCount, in_range_values, "results", bool)	
	return newDataset

```

[Ignition Extensions](https://forum.inductiveautomation.com/t/ignition-extensions-convenience-utilities-for-advanced-users/64615#systemdatasetfilterdataset-filter-dataset-9), my free convenience function module, also adds a `system.dataset.filter` function, so you could rewrite your code as:

```python
def transform(self, value, quality, timestamp):
	in_range_values = []
	colCount = value.getColumnCount()
	for row in range(value.getRowCount()):
		in_range_values.append(16 < value.getValueAt(row,1) < 27)
	addedColumn = system.dataset.addColumn(rowsRemoved, colCount, in_range_values, "results", bool)
	newDataset = system.dataset.filter(addedColumn, lambda **columns: columns["results"])
	return newDataset

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 12, 2023, 6:25pm UTC](https://forum.inductiveautomation.com/t/show-only-true-rows-in-perspective-table/72362/4 "2023-04-12T18:25:39Z")

</div>

Assuming you don't need to add the `results` column anymore, since it's all gonna be `True` anyway:

```python
def transform(self, value, quality, timestamp):
    return [row for row in system.dataset.toPyDataSet(value) if 16 < row[1] < 27]

```

Maybe not the most efficient, but it's simple and clear, which unless you notice a difference is probably more important than performances.

edit: You may or may not need to re-transform things back to a dataset. In which case:

```python
def transform(self, value, quality, timestamp):
    headers = value.getColumnNames()
    data = [row for row in system.dataset.toPyDataSet(value) if 16 < row[1] < 27] 
    return system.dataset.toDataSet(headers, data)

```
