# A better way to create dataset using script

**URL:** <https://forum.inductiveautomation.com/t/a-better-way-to-create-dataset-using-script/79193>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 15, 2023, 12:29am UTC](https://forum.inductiveautomation.com/t/a-better-way-to-create-dataset-using-script/79193 "2023-09-15T00:29:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [September 15, 2023, 12:29am UTC](https://forum.inductiveautomation.com/t/a-better-way-to-create-dataset-using-script/79193/1 "2023-09-15T00:29:24Z")

</div>

I am current using the following way to create a dataset using python:

1. clicking binding.
2. choose expression.
3. enter "1" in expression.
4. add a transform, choose script.
5. enter script to create a dataset.
6. pass the dataset to return.

It works fine, but from time to time I found that the dataset does not refresh unless I leave the view and return, or using refreshbinding command.

Is there any better way to create a dataset that can be refreshed automatically by defined time interval?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/3/d32ae96fe5ab156a38dc7eaa86f190073dc3d238.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:** [September 15, 2023, 12:46am UTC](https://forum.inductiveautomation.com/t/a-better-way-to-create-dataset-using-script/79193/2 "2023-09-15T00:46:49Z")

</div>

Instead of using a constant expression, use `now(1000)` or similar. Or better, make a function in a project library script that you can call to make the dataset. Then your expression would be just:

```auto
runScript('somelibrary.somescript.somefunction', 1000)

```

Adjust the poll time as desired. No transform required. (Single `runScript()` has less overhead than expression+transform.)

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [September 15, 2023, 12:54am UTC](https://forum.inductiveautomation.com/t/a-better-way-to-create-dataset-using-script/79193/3 "2023-09-15T00:54:08Z")

</div>

Great idea.  
Now I get work to be done during the weekend.
