# "Close Match" variable comparison in event script

**URL:** <https://forum.inductiveautomation.com/t/close-match-variable-comparison-in-event-script/56409>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [February 22, 2022, 1:29pm UTC](https://forum.inductiveautomation.com/t/close-match-variable-comparison-in-event-script/56409 "2022-02-22T13:29:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blogsdon](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@blogsdon](https://forum.inductiveautomation.com/u/blogsdon)\
**Post date:** [February 22, 2022, 1:29pm UTC](https://forum.inductiveautomation.com/t/close-match-variable-comparison-in-event-script/56409/1 "2022-02-22T13:29:53Z")

</div>

In the script below I am trimming a dataset to exclude rows where the “Approved\_Workcenters” column does not match the local variable “wc”. The change I need to make is to keep rows from the dataset that match “wc” even as a partial match. For example, if wc = “G5-04E” and a row in the dataset has “G5-04E, G5-04W” in the “Approved\_Workcenter” column, keep this row. Any suggestions?

```
rack1 = system.tag.read("[default]KanbanRackCalls/WeldRacksActual").value
	
	wc = system.tag.read("[.]../Workcenter").value
	
	rack2 = system.dataset.toPyDataSet(rack1)
	
	y = len(rack2)
	x=0
	delete = []
	
	while x < y:
		if rack2[x]['Approved_Workcenters'] != wc:
			delete = delete + [x]
		x=x+1
	
	rack3 = system.dataset.deleteRows(rack1, delete)	
				
		
	system.tag.write("[.]KanbanDisplay", rack3)
```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 22, 2022, 2:09pm UTC](https://forum.inductiveautomation.com/t/close-match-variable-comparison-in-event-script/56409/2 "2022-02-22T14:09:33Z")

</div>

It looks like you are on version 7.9? Below is an untested script that should help.

```auto
paths = ["[default]KanbanRackCalls/WeldRacksActual","[.]../Workcenter"]
tags = system.tag.readAll(paths)
rack1 = tags[0].value
wc = tags[1].value
rowsToDelete = []
rack2 = system.dataset.toPyDataSet(rack1) 
for i,row in enumerate(rack2):
	if wc not in row["Approved_Workcenters"]:
		rowsToDelete.append(i)
dataOut = system.dataset.deleteRows(rack,rowsToDelete)
system.tag.write("[.]KanbanDisplay", rack3)

```
