# Script to compare and return dataset values

**URL:** <https://forum.inductiveautomation.com/t/script-to-compare-and-return-dataset-values/47462>\
**Category:** Ignition\
**Created:** [June 4, 2021, 3:05pm UTC](https://forum.inductiveautomation.com/t/script-to-compare-and-return-dataset-values/47462 "2021-06-04T15:05:00Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 4, 2021, 7:22pm UTC](https://forum.inductiveautomation.com/t/script-to-compare-and-return-dataset-values/47462/8 "2021-06-04T19:22:54Z")

</div>

You can get column data as a list. Use that list with `system.tag.readBlocking` to get all your values at once.

I’d also recommend converting to a PyDataSet to make it convenient to iterate through the data.

```auto
def myFunc(datasetPath):
	# Read the dataset tag. Convert to PyDataSet for easier iteration.
	dataIn = system.dataset.toPyDataSet(system.tag.readBlocking([datasetPath])[0].value)

	# Get column names. Coerce it to a list to use the same names in the new dataset.
	headers = list(dataIn.getColumnNames())
	
	# Get tag paths as a list
	tagList = dataIn.getColumnAsList(headers.index('InterlockedTags'))

	# Read the tags
	tagValues = [tag.value for tag in system.tag.readBlocking(tagList)]

	# Construct the new dataset.
	data = []
	for row, actualValue in zip(dataIn, tagValues): 
		data.append([row['InterlockedTags'], row['StatusForTrue'], int(row['StatusForTrue'] != actualValue)])
	
	# Write back to the original tag
	system.tag.writeBlocking([datasetPath],[system.dataset.toDataSet(headers, data)])

myFunc('[default]path/to/Interlock')

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/script-to-compare-and-return-dataset-values/47462)._
