# Extracting row and column data from pydataset

**URL:** <https://forum.inductiveautomation.com/t/extracting-row-and-column-data-from-pydataset/14034>\
**Category:** Ignition\
**Created:** [April 12, 2017, 9:18pm UTC](https://forum.inductiveautomation.com/t/extracting-row-and-column-data-from-pydataset/14034 "2017-04-12T21:18:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [April 12, 2017, 9:18pm UTC](https://forum.inductiveautomation.com/t/extracting-row-and-column-data-from-pydataset/14034/1 "2017-04-12T21:18:55Z")

</div>

I am doing an SQL query which will return one row.  
I need to create a pydict of key:value pairs based on the column headers and row data.

So far i have managed to use the following code from another topic) to extract column headers as a list.  
But i can’t get a python list out of the row data.

```
pydata = system.db.runPrepQuery(query ,args ,db)
keys = list(pydata.getUnderlyingDataset().getColumnNames())
values = list(pydata.getUnderlyingDataset().getData())

```

The ‘values’ object is an annoying java.lang.object array type.  
I could always use a loop through the dataset to extract the row values into a list, but i was just trying to avoid using a loop if possible.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [April 12, 2017, 9:48pm UTC](https://forum.inductiveautomation.com/t/extracting-row-and-column-data-from-pydataset/14034/2 "2017-04-12T21:48:55Z")

</div>

> [@richardNZ15](#):
>
> getUnderlyingDataset()

```
pydata = system.db.runPrepQuery(query ,args ,db)
columnHeaders = system.dataset.getColumnHeaders(pydata.getUnderlyingDataset())

print dict(zip(columnHeaders, pydata[0]))

```
