# Issue in writing into Dataset Tag

**URL:** <https://forum.inductiveautomation.com/t/issue-in-writing-into-dataset-tag/88536>\
**Category:** Ignition\
**Tags:** ignition80, ignition81, perspective\
**Created:** [April 8, 2024, 6:05pm UTC](https://forum.inductiveautomation.com/t/issue-in-writing-into-dataset-tag/88536 "2024-04-08T18:05:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahad99.shalwani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahad99.shalwani/32/76824_2.png) [@ahad99.shalwani](https://forum.inductiveautomation.com/u/ahad99.shalwani)\
**Post date:** [April 8, 2024, 6:05pm UTC](https://forum.inductiveautomation.com/t/issue-in-writing-into-dataset-tag/88536/1 "2024-04-08T18:05:48Z")

</div>

Hi All,

I have this dataset:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/0/e098996408b3ea28b4cd129fdc718d335709a70a.png)

which I am trying to write on a dataset type tag on button action. The script on button action is this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/b/3ba6f07e7b064930256bb55afd18d244c1d42b1e.png)

When I click on the button it shows this issue:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0b8b0eee544e2a504f01516d53b6bdde56eb7f4e.png)

I have this tag on which Im tring to write

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/38db3a446846f4ea4822f7c3623a2f4d526b0a19.png)

How to fix length issue?

---

<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 8, 2024, 6:13pm UTC](https://forum.inductiveautomation.com/t/issue-in-writing-into-dataset-tag/88536/2 "2024-04-08T18:13:51Z")

</div>

> [@ahad99.shalwani](#):
>
> I have this dataset

That's not a dataset. That's a list of dictionaries.

> [@ahad99.shalwani](#):
>
> shows this issue

You are giving `writeBlocking()` one tag path and two values in a list. It needs the same number of paths as values. (Using a string tagpath outside a list is a legacy support loophole--don't do that in new code.)

What kind of data are you trying to get as a result in your tag?

---

<div class="post-metadata">

**Author:** ![ahad99.shalwani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahad99.shalwani/32/76824_2.png) [@ahad99.shalwani](https://forum.inductiveautomation.com/u/ahad99.shalwani)\
**Post date:** [April 8, 2024, 6:17pm UTC](https://forum.inductiveautomation.com/t/issue-in-writing-into-dataset-tag/88536/3 "2024-04-08T18:17:57Z")

</div>

I am getting data from an API call which is list of dictionaries. I need this to be inserted into dataset tag. I was looking for a system dataset function for this case but have not found how to convert it.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [April 8, 2024, 6:37pm UTC](https://forum.inductiveautomation.com/t/issue-in-writing-into-dataset-tag/88536/5 "2024-04-08T18:37:09Z")

</div>

You will probably have to roll your own conversion method for converting from the api response to a dataset.

A quick dirty conversion function:

```auto
def dictsToDataset(dicts, columns=None):
	""" """
	if not dicts:
		return system.dataset.toDataSet([], [[]])

	if not columns:
		columns = dicts[0].keys()

	data = [[item[column] for column in columns] for item in dicts]

	return system.dataset.toDataSet(columns, data)

```

Will probably work, but the dataset will make assumptions on the column types. If you need explicit control over the column data types, then make a function that uses the [DatasetBuilder](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.25/com/inductiveautomation/ignition/common/util/DatasetBuilder.html) class to explicitly define the column types and build a dataset.
