# Dataset Dimensions

**URL:** <https://forum.inductiveautomation.com/t/dataset-dimensions/90078>\
**Category:** Ignition Exchange\
**Tags:** scripting\
**Created:** [May 8, 2024, 3:20am UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078 "2024-05-08T03:20:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam.Taylor](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Sam.Taylor](https://forum.inductiveautomation.com/u/Sam.Taylor)\
**Post date:** [May 8, 2024, 3:20am UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078/1 "2024-05-08T03:20:50Z")

</div>

A system function that could tell you how many rows and how many columns a dataset has would be really useful. Thoughts?

---

<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, 2024, 4:24am UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078/2 "2024-05-08T04:24:01Z")

</div>

Why do you need a system function for this?  
You can just ask the instance you have directly. PyDatasets will also accurately report row count to the Python `len()` builtin.

In an expression context, the `len()` builtin will also work for datasets.

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [May 8, 2024, 6:00am UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078/3 "2024-05-08T06:00:43Z")

</div>

There are actually a lot of great functions that a dataset has inherently.

`data = system.dataset.toDataSet(["Column 1", "Column 2"],[[100, 200]])`  
`print data.getRowCount()`  
`print data.getColumnCount()`  
`print data.getColumnNames()`

> **[Datasets | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/platform/scripting/python-scripting/variables-datatypes-and-objects/datasets)**
>
> Datasets and PyDatasets

As Paul said, you can certainly use pythonic features as well with a PyDataSet.

`dataset = system.dataset.toDataSet(["Column 1", "Column 2"],[[100, 200]])`  
`data = system.dataset.toPyDataSet(dataset)`  
`print len(data) # Row Count`  
`print len(data[0]) # Column Count`

It's possible someday we'll also support `data[0].keys()` to get the column names, but we don't have support yet as of today.

---

<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:** [May 8, 2024, 9:44am UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078/4 "2024-05-08T09:44:26Z")

</div>

> [@Kevin.McClusky](#):
>
> `data = system.dataset.toDataSet(["Column 1", "Column 2"],[[100, 200]])`  
> `print data.getRowCount()`  
> `print data.getColumnCount()`  
> `print data.getColumnNames()`

There are also properties:

```python
data = system.dataset.toDataSet(["Column 1", "Column 2"],[[100, 200]])
print data.rowCount
print data.columnCount
print data.columnNames

```

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [May 8, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078/5 "2024-05-08T15:54:23Z")

</div>

Power user tip:

Most objects that have "getter" functions in Ignition's objects provide access to those same functions using property accessors.

data.getRowCount() and data.rowCount hit the same function behind the scenes.

You can try it on other get\*() functions in Ignition's objects too!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 8, 2024, 6:14pm UTC](https://forum.inductiveautomation.com/t/dataset-dimensions/90078/6 "2024-05-08T18:14:44Z")

</div>

> [@Kevin.McClusky](#):
>
> Power user tip:
> 
> Most objects that have "getter" functions in Ignition's objects provide access to those same functions using property accessors.

These are also more performant.
