# Grabbing one full row out of a table as a dataset?

**URL:** <https://forum.inductiveautomation.com/t/grabbing-one-full-row-out-of-a-table-as-a-dataset/34571>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [May 8, 2020, 2:05pm UTC](https://forum.inductiveautomation.com/t/grabbing-one-full-row-out-of-a-table-as-a-dataset/34571 "2020-05-08T14:05:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [May 8, 2020, 2:05pm UTC](https://forum.inductiveautomation.com/t/grabbing-one-full-row-out-of-a-table-as-a-dataset/34571/1 "2020-05-08T14:05:42Z")

</div>

I have a window that accepts a dataset as a parameter that comes from a parent window. Previously this was calculated by running a query, but there must be a way to get that full row as a dataset. How can I do that?

For instance, I have a table with a bound sql data query, and I want to get the 5th row as it’s own dataset.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [May 8, 2020, 2:53pm UTC](https://forum.inductiveautomation.com/t/grabbing-one-full-row-out-of-a-table-as-a-dataset/34571/2 "2020-05-08T14:53:18Z")

</div>

Answer for anyone else seeking a solution, what I came up with

```auto
def getRow(data, row):
	"""
	Input table data and row you want to get a dataset from
	Args:
		data: Dataset, ususally table.data, but works with other datasets as well
		row: int, what row do you want?
	Returns:
		dataset: 1R x MC, where M is the number of columns in the datset
	"""
	import system.dataset
	
	columns = map(str,data.columnNames)
	values = []
	for col in data.columnNames:
		values.append(data.getValueAt(row, col))
	return system.dataset.toDataSet(columns, [values])

```

Why do I map the str to the data.columnNames? Because system.dataset didn’t like it otherwise. Not sure why. But this works.

---

<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:** [May 8, 2020, 3:22pm UTC](https://forum.inductiveautomation.com/t/grabbing-one-full-row-out-of-a-table-as-a-dataset/34571/3 "2020-05-08T15:22:21Z")

</div>

`data.columnNames` is a string array on the Java side, but the `system.dataset.toDataSet` function requires a list of strings. You could also just `list(data.columnNames)` to do the appropriate conversion.

You could also write your function with `system.dataset.deleteRows`

```auto
def getRow(data, row):
	"""
	Input table data and row you want to get a dataset from
	Args:
		data: Dataset, ususally table.data, but works with other datasets as well
		row: int, what row do you want?
	Returns:
		dataset: 1R x MC, where M is the number of columns in the datset
	"""
	return system.dataset.deleteRows(data, [i for i in xrange(data.rowCount) if i != row])

```
