# Empty cells in dataset

**URL:** <https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425>\
**Category:** Ignition\
**Tags:** database, datascience, scripting, perspective\
**Created:** [April 5, 2024, 1:29pm UTC](https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425 "2024-04-05T13:29:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lowie\_Vanhaesbrouck](https://avatars.discourse-cdn.com/v4/letter/l/5e9695/32.png) [@Lowie\_Vanhaesbrouck](https://forum.inductiveautomation.com/u/Lowie_Vanhaesbrouck)\
**Post date:** [April 5, 2024, 1:29pm UTC](https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425/1 "2024-04-05T13:29:32Z")

</div>

I have a dataset that has the history from a few tags in it. Each tag has its own colomn. But the tags save histroy at different times (for example : tag1 : each 15m  
tag2 : each 5 m) You get what I mean. This results in a few empty cells in the beginning of the tag history. Can anyone explain how I can script it to search for the first row with all values there? I have been looking and trying for a long time now.

 ![Schermafbeelding 2024-04-05 143401](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8b3ae145f00f24a1ddbb34362fe9f6fa7605acb7.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 5, 2024, 2:06pm UTC](https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425/2 "2024-04-05T14:06:23Z")

</div>

To avoid this scrambling of data at multiple timestamps, always use "tall" format when retrieving "as stored" data..

---

<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:** [April 5, 2024, 2:31pm UTC](https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425/3 "2024-04-05T14:31:47Z")

</div>

If for whatever reason you can not change to using a tall format instead of a wide, this function will return the t\_stamp column of the first row that has a value other than `None` (or 0 which may or may not be an issue but can be fixed if needed).

```auto
def getFirstFullRow(dataset):
    ds = system.dataset.toPyDataSet(dataset)

    for row in ds:
        col = 1
        while row[col]:
            col += 1
            if col == ds.columnCount:
                return row[0]

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 5, 2024, 3:04pm UTC](https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425/4 "2024-04-05T15:04:16Z")

</div>

I'll suggest another version that I believe is easier to understand:

```python
def get_first_full_row(ds):
	ds = system.dataset.toPyDataSet(ds)
	return next(
		(row for row in ds if all(c is not None for c in row)),
		None
	)

ffr = get_first_full_row(ds)
tstamp = ffr[0] if ffr is not None else 0

```

edit: wait, this doesn't actually check for nulls, but for "falsy" values.  
Gimme a sec to fix it  
edit2: updated

---

<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:** [April 5, 2024, 3:09pm UTC](https://forum.inductiveautomation.com/t/empty-cells-in-dataset/88425/5 "2024-04-05T15:09:17Z")

</div>

> [@pascal.fragnoud](#):
>
> but for "falsy" values.  
> Gimme a sec to fix it

Neither does mine
